From edcdaa8fd2453227b19f1145c888db77c03e5eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 8 May 2023 23:27:47 +0200 Subject: [PATCH] download: fix parsing of var id, better error handling --- download_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/download_data.py b/download_data.py index da0d957..9aa2d55 100644 --- a/download_data.py +++ b/download_data.py @@ -38,6 +38,7 @@ def export_game(game_id) -> [bool, bool]: res = cur.fetchall() if len(res) == 1: print(res) + return else: print('game is completely new') # return @@ -53,7 +54,7 @@ def export_game(game_id) -> [bool, bool]: num_players = len(r['players']) seed = r['seed'] options = r.get('options', {}) - var_id = variant_id(options['variant']) + var_id = variant_id(options.get('variant', 'No Variant')) deck_plays = options.get('deckPlays', False) one_extra_card = options.get('oneExtraCard', False) one_less_card = options.get('oneLessCard', False) @@ -62,6 +63,7 @@ def export_game(game_id) -> [bool, bool]: deck = [DeckCard.from_json(card) for card in r['deck']] except KeyError: print('Error parsing JSON when exporting game {}'.format(game_id)) + raise # need to play through the game once to find out its score game = GameState(HanabiInstance(deck, num_players))