From 3ab35eb10d6c6eb53f6e87b565542159851ab59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 7 Jul 2023 14:20:24 +0200 Subject: [PATCH] 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. --- hanabi/database/games_seeds_schema.sql | 2 +- hanabi/live/download_data.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hanabi/database/games_seeds_schema.sql b/hanabi/database/games_seeds_schema.sql index 01b22e0..9b43b28 100644 --- a/hanabi/database/games_seeds_schema.sql +++ b/hanabi/database/games_seeds_schema.sql @@ -4,6 +4,7 @@ CREATE TABLE seeds ( num_players SMALLINT NOT NULL, variant_id SMALLINT NOT NULL, deck VARCHAR(62) NOT NULL, + starting_player SMALLINT NOT NULL DEFAULT 0, feasible BOOLEAN DEFAULT NULL, max_score_theoretical SMALLINT ); @@ -15,7 +16,6 @@ CREATE TABLE games ( id INT PRIMARY KEY, seed TEXT NOT NULL REFERENCES seeds, num_players SMALLINT NOT NULL, - starting_player SMALLINT NOT NULL DEFAULT 0, score SMALLINT NOT NULL, variant_id SMALLINT NOT NULL, deck_plays BOOLEAN, diff --git a/hanabi/live/download_data.py b/hanabi/live/download_data.py index 0fc8427..0076933 100644 --- a/hanabi/live/download_data.py +++ b/hanabi/live/download_data.py @@ -140,19 +140,19 @@ def detailed_export_game( if not seed_exists: database.cur.execute( - "INSERT INTO seeds (seed, num_players, variant_id, deck)" - "VALUES (%s, %s, %s, %s)" + "INSERT INTO seeds (seed, num_players, starting_player, variant_id, deck)" + "VALUES (%s, %s, %s, %s, %s)" "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)) database.cur.execute( "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" ")" - "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 (" "deck_plays, one_extra_card, one_less_card, all_or_nothing, actions" ") = (" @@ -160,7 +160,7 @@ def detailed_export_game( "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 ) )