add more comments and restrictions on properties of variants. calculate available clues in each variant
This commit is contained in:
parent
c0f007c15c
commit
7d8e03fca0
2 changed files with 40 additions and 1 deletions
|
@ -56,7 +56,25 @@ CREATE TABLE variants (
|
||||||
name TEXT NOT NULL UNIQUE,
|
name TEXT NOT NULL UNIQUE,
|
||||||
clue_starved BOOLEAN NOT NULL DEFAULT FALSE,
|
clue_starved BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
throw_it_in_a_hole BOOLEAN NOT NULL DEFAULT FALSE,
|
throw_it_in_a_hole BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
/**
|
||||||
|
If set to true, the clue types (color, rank) have to be alternating during the game.
|
||||||
|
The type of the starting clue can still be freely chosen
|
||||||
|
Mutually exclusive with no_color_clues and no_rank_clues
|
||||||
|
*/
|
||||||
alternating_clues BOOLEAN NOT NULL DEFAULT FALSE,
|
alternating_clues BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
/**
|
||||||
|
If set to true, no rank clues can be given
|
||||||
|
Instead, any color given is interpreted as a simultaneous rank clue at the same time,
|
||||||
|
where the colors correspond in order to the available ranks, wrapping around if necessary.
|
||||||
|
To be precise,
|
||||||
|
if (r_1, r_2, ..., r_k) are the available rank clues in the variant
|
||||||
|
and (c_1, c_2, ..., c_l) are the available color clues in the variant,
|
||||||
|
then color clue c_i will be interpreted simultaneously as all rank clues r_j with i == j (mod l).
|
||||||
|
Note that this means that if there are more colors clues than rank clues,
|
||||||
|
some color clues are not hybrid rank clues, and conversely, if there are less color clues than rank clues,
|
||||||
|
then some colors will be interpreted as multiple rank clues at the same time.
|
||||||
|
Mutually exclusive with no_color_clues
|
||||||
|
*/
|
||||||
synesthesia BOOLEAN NOT NULL DEFAULT FALSE,
|
synesthesia BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
chimneys BOOLEAN NOT NULL DEFAULT FALSE,
|
chimneys BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
funnels BOOLEAN NOT NULL DEFAULT FALSE,
|
funnels BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
@ -93,7 +111,16 @@ CREATE TABLE variants (
|
||||||
If set, special_rank_ranks has to be set to 1
|
If set, special_rank_ranks has to be set to 1
|
||||||
*/
|
*/
|
||||||
special_deceptive BOOLEAN NOT NULL DEFAULT FALSE,
|
special_deceptive BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
CHECK (special_rank_ranks = 1 OR special_deceptive IS FALSE)
|
CHECK (special_rank_ranks = 1 OR special_deceptive IS FALSE),
|
||||||
|
CHECK (funnels IS FALSE OR chimneys IS FALSE),
|
||||||
|
CHECK (funnels IS FALSE OR odds_and_evens IS FALSE),
|
||||||
|
CHECK (chimneys IS FALSE OR odds_and_evens IS FALSE),
|
||||||
|
CHECK (no_rank_clues IS FALSE OR empty_rank_clues IS FALSE),
|
||||||
|
CHECK (no_color_clues IS FALSE OR empty_color_clues IS FALSE),
|
||||||
|
CHECK (no_color_clues IS FALSE OR no_rank_clues IS FALSE),
|
||||||
|
CHECK (no_rank_clues IS FALSE OR alternating_clues IS FALSE),
|
||||||
|
CHECK (no_color_clues IS FALSE OR alternating_clues IS FALSE),
|
||||||
|
CHECK (no_color_clues IS FALSE OR synesthesia IS FALSE)
|
||||||
);
|
);
|
||||||
CREATE INDEX variants_name_idx ON variants (name);
|
CREATE INDEX variants_name_idx ON variants (name);
|
||||||
|
|
||||||
|
|
12
variants.py
12
variants.py
|
@ -109,6 +109,18 @@ class Variant:
|
||||||
if color not in self.colors:
|
if color not in self.colors:
|
||||||
self.colors.append(color)
|
self.colors.append(color)
|
||||||
|
|
||||||
|
self.ranks = [1, 2, 3, 4, 5]
|
||||||
|
if self.special_rank and self.special_rank_ranks != ClueBehaviour.default:
|
||||||
|
self.ranks.remove(self.special_rank)
|
||||||
|
if self.odds_and_evens:
|
||||||
|
self.ranks = sorted([
|
||||||
|
next(i for i in self.ranks if i % 2 == 0),
|
||||||
|
next(i for i in self.ranks if i % 2 == 1)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if self.no_rank_clues or self.synesthesia:
|
||||||
|
self.ranks = []
|
||||||
|
|
||||||
self.num_colors = len(self.colors)
|
self.num_colors = len(self.colors)
|
||||||
|
|
||||||
def rank_touches(self, card: DeckCard, value: int):
|
def rank_touches(self, card: DeckCard, value: int):
|
||||||
|
|
Loading…
Reference in a new issue