Exemplo n.º 1
0
 def serialization_copy(old_game):
     game_json = json.dumps(old_game, default=_save_object, indent=2)
     d = json.loads(game_json)
     game = Game.__from_json__(
         d, [player.agent for player in old_game.players])
     game._has_turn_ended = old_game._has_turn_ended
     return game
Exemplo n.º 2
0
def deserialize(json_string, agents):
    """
    Decode the given game instance from a JSON formatted string.

    :param string json_string: The string representation of the game
    :rtype: :class:`hearthbreaker.engine.Game`
    """
    d = json.loads(json_string)
    return Game.__from_json__(d, agents)
Exemplo n.º 3
0
def _load_object(d):
    return Game.__from_json__(d)
 def serialization_copy(old_game):
     game_json = json.dumps(old_game, default=_save_object, indent=2)
     d = json.loads(game_json)
     game = Game.__from_json__(d, [player.agent for player in old_game.players])
     game._has_turn_ended = old_game._has_turn_ended
     return game