rename database fields

This commit is contained in:
Maximilian Keßler 2023-05-12 23:15:53 +02:00
parent 49792f530d
commit b133e86769
Signed by: max
GPG Key ID: BCC5A619923C0BA5
2 changed files with 8 additions and 8 deletions

View File

@ -76,7 +76,7 @@ def init_static_tables():
create = True create = True
if not create: if not create:
return pass
# init tables in database # init tables in database
with open("variant_suits_schema.sql", "r") as f: with open("variant_suits_schema.sql", "r") as f:
@ -109,10 +109,10 @@ def init_static_tables():
assert([all_colors, no_color_clues, prism].count(True) <= 1) assert([all_colors, no_color_clues, prism].count(True) <= 1)
assert(not all([no_rank_clues, all_ranks])) assert(not all([no_rank_clues, all_ranks]))
colors = 2 if all_colors else (0 if no_color_clues else 1) color_clues = 2 if all_colors else (0 if no_color_clues else 1)
ranks = 2 if all_ranks else (0 if no_rank_clues else 1) rank_clues = 2 if all_ranks else (0 if no_rank_clues else 1)
clue_colors = suit.get('clueColors', [name] if (colors == 1 and not prism) else []) clue_colors = suit.get('clueColors', [name] if (color_clues == 1 and not prism) else [])
for rev in [False, True]: for rev in [False, True]:
if rev is True and name not in suits_to_reverse: if rev is True and name not in suits_to_reverse:
@ -120,10 +120,10 @@ def init_static_tables():
suit_name = name suit_name = name
suit_name += ' Reversed' if rev else '' suit_name += ' Reversed' if rev else ''
cur.execute( cur.execute(
"INSERT INTO suits (name, display_name, abbreviation, ranks, colors, dark, reversed, prism)" "INSERT INTO suits (name, display_name, abbreviation, rank_clues, color_clues, dark, reversed, prism)"
"VALUES" "VALUES"
"(%s, %s, %s, %s, %s, %s, %s, %s)", "(%s, %s, %s, %s, %s, %s, %s, %s)",
(suit_name, display_name, abbreviation, ranks, colors, dark, rev, prism) (suit_name, display_name, abbreviation, rank_clues, color_clues, dark, rev, prism)
) )
cur.execute( cur.execute(
"SELECT id FROM suits WHERE name = %s", "SELECT id FROM suits WHERE name = %s",

View File

@ -13,14 +13,14 @@ CREATE TABLE suits (
1: touched by actual rank of the cards 1: touched by actual rank of the cards
2: touched by all ranks 2: touched by all ranks
*/ */
ranks SMALLINT NOT NULL DEFAULT 1, rank_clues SMALLINT NOT NULL DEFAULT 1,
/** /**
This encodes how cards of this suit behave under color clues, we use: This encodes how cards of this suit behave under color clues, we use:
0: not touched by color, 0: not touched by color,
1: touched by native colors, 1: touched by native colors,
2: touched by all colors 2: touched by all colors
*/ */
colors SMALLINT NOT NULL DEFAULT 1, color_clues SMALLINT NOT NULL DEFAULT 1,
prism BOOLEAN NOT NULL DEFAULT FALSE, prism BOOLEAN NOT NULL DEFAULT FALSE,
dark BOOLEAN NOT NULL DEFAULT FALSE, dark BOOLEAN NOT NULL DEFAULT FALSE,
reversed BOOLEAN NOT NULL DEFAULT FALSE reversed BOOLEAN NOT NULL DEFAULT FALSE