def shift_action_to_dto(location, rotation): """ Maps a shift location and the rotation of the leftover maze card to a DTO, which is valid for the POST shift method of the API """ return { "location": _board_location_to_dto(location), "leftoverRotation": rotation }
def game_to_dto(game: Game): """Maps a game to a DTO, which can be restored with dto_to_game() :param game: an instance of model.Game :return: a structure which can be encoded into JSON and decoded into a Game """ return { ID: game.identifier, PLAYERS: [_player_to_dto(player) for player in game.players], MAZE: _board_to_dto(game.board), NEXT_ACTION: _turns_to_next_action_dto(game.turns), TURN_PREPARE_DELAY: _timedelta_to_dto_(game.turns.prepare_delay), OBJECTIVE: _objective_to_dto(game.board.objective_maze_card), PREVIOUS_SHIFT_LOCATION: _board_location_to_dto(game.previous_shift_location) }
def move_action_to_dto(move_location): """ Maps a location to a DTO, which is valid for the POST move method of the API """ return {"location": _board_location_to_dto(move_location)}