make starting_player an attribute of seeds instead of games
Since all games on a particular seed have the same starting player, we should store this accordingly. Note that this option is only used for old seeds (before 2020) from the hanab.live database. Regardless, we need to support this to be able to support these old games.
This commit is contained in:
parent
fb645b47b4
commit
3ab35eb10d
2 changed files with 7 additions and 7 deletions
|
@ -4,6 +4,7 @@ CREATE TABLE seeds (
|
||||||
num_players SMALLINT NOT NULL,
|
num_players SMALLINT NOT NULL,
|
||||||
variant_id SMALLINT NOT NULL,
|
variant_id SMALLINT NOT NULL,
|
||||||
deck VARCHAR(62) NOT NULL,
|
deck VARCHAR(62) NOT NULL,
|
||||||
|
starting_player SMALLINT NOT NULL DEFAULT 0,
|
||||||
feasible BOOLEAN DEFAULT NULL,
|
feasible BOOLEAN DEFAULT NULL,
|
||||||
max_score_theoretical SMALLINT
|
max_score_theoretical SMALLINT
|
||||||
);
|
);
|
||||||
|
@ -15,7 +16,6 @@ CREATE TABLE games (
|
||||||
id INT PRIMARY KEY,
|
id INT PRIMARY KEY,
|
||||||
seed TEXT NOT NULL REFERENCES seeds,
|
seed TEXT NOT NULL REFERENCES seeds,
|
||||||
num_players SMALLINT NOT NULL,
|
num_players SMALLINT NOT NULL,
|
||||||
starting_player SMALLINT NOT NULL DEFAULT 0,
|
|
||||||
score SMALLINT NOT NULL,
|
score SMALLINT NOT NULL,
|
||||||
variant_id SMALLINT NOT NULL,
|
variant_id SMALLINT NOT NULL,
|
||||||
deck_plays BOOLEAN,
|
deck_plays BOOLEAN,
|
||||||
|
|
|
@ -140,19 +140,19 @@ def detailed_export_game(
|
||||||
|
|
||||||
if not seed_exists:
|
if not seed_exists:
|
||||||
database.cur.execute(
|
database.cur.execute(
|
||||||
"INSERT INTO seeds (seed, num_players, variant_id, deck)"
|
"INSERT INTO seeds (seed, num_players, starting_player, variant_id, deck)"
|
||||||
"VALUES (%s, %s, %s, %s)"
|
"VALUES (%s, %s, %s, %s, %s)"
|
||||||
"ON CONFLICT (seed) DO NOTHING",
|
"ON CONFLICT (seed) DO NOTHING",
|
||||||
(seed, num_players, var_id, compressed_deck)
|
(seed, num_players, starting_player, var_id, compressed_deck)
|
||||||
)
|
)
|
||||||
logger.debug("New seed {} imported.".format(seed))
|
logger.debug("New seed {} imported.".format(seed))
|
||||||
|
|
||||||
database.cur.execute(
|
database.cur.execute(
|
||||||
"INSERT INTO games ("
|
"INSERT INTO games ("
|
||||||
"id, num_players, starting_player, score, seed, variant_id, deck_plays, one_extra_card, one_less_card,"
|
"id, num_players, score, seed, variant_id, deck_plays, one_extra_card, one_less_card,"
|
||||||
"all_or_nothing, actions"
|
"all_or_nothing, actions"
|
||||||
")"
|
")"
|
||||||
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||||
"ON CONFLICT (id) DO UPDATE SET ("
|
"ON CONFLICT (id) DO UPDATE SET ("
|
||||||
"deck_plays, one_extra_card, one_less_card, all_or_nothing, actions"
|
"deck_plays, one_extra_card, one_less_card, all_or_nothing, actions"
|
||||||
") = ("
|
") = ("
|
||||||
|
@ -160,7 +160,7 @@ def detailed_export_game(
|
||||||
"EXCLUDED.actions"
|
"EXCLUDED.actions"
|
||||||
")",
|
")",
|
||||||
(
|
(
|
||||||
game_id, num_players, starting_player, score, seed, var_id, deck_plays, one_extra_card, one_less_card,
|
game_id, num_players, score, seed, var_id, deck_plays, one_extra_card, one_less_card,
|
||||||
all_or_nothing, compressed_actions
|
all_or_nothing, compressed_actions
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue