fix generation of links

This commit is contained in:
Maximilian Keßler 2023-05-20 14:31:43 +02:00
parent ef4b344762
commit 85c9dbd646
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -167,11 +167,11 @@ def decompress_deck(deck_str: str) -> List[DeckCard]:
# otherwise compression is not possible # otherwise compression is not possible
def compress_game_state(state: Union[GameState, HanabLiveGameState]) -> str: def compress_game_state(state: Union[GameState, HanabLiveGameState]) -> str:
var_id = -1 var_id = -1
if isinstance(state, GameState): if isinstance(state, HanabLiveGameState):
var_id = HanabLiveInstance.select_standard_variant_id(state.instance)
else:
assert isinstance(state, HanabLiveGameState)
var_id = state.instance.variant_id var_id = state.instance.variant_id
else:
assert isinstance(state, GameState)
var_id = HanabLiveInstance.select_standard_variant_id(state.instance)
out = "{}{},{},{}".format( out = "{}{},{},{}".format(
state.instance.num_players, state.instance.num_players,
compress_deck(state.instance.deck), compress_deck(state.instance.deck),
@ -216,7 +216,7 @@ def decompress_game_state(game_str: str) -> GameState:
except ValueError: except ValueError:
raise ValueError("Expected variant id, found: {}".format(variant_id)) raise ValueError("Expected variant id, found: {}".format(variant_id))
instance = HanabiInstance(deck, num_players, variant_id=variant_id) instance = HanabiInstance(deck, num_players)
game = GameState(instance) game = GameState(instance)
# TODO: game is not in consistent state # TODO: game is not in consistent state
@ -226,7 +226,7 @@ def decompress_game_state(game_str: str) -> GameState:
def link(game_state: GameState) -> str: def link(game_state: GameState) -> str:
compressed = compress_game_state(game_state) compressed = compress_game_state(game_state)
return "https://hanab.live/replay-json/{}".format(compressed) return "https://hanab.live/shared-replay-json/{}".format(compressed)
# add link method to GameState class # add link method to GameState class