load endgame actions from db
This commit is contained in:
parent
5c6c8a6b14
commit
bfe83d4f43
1 changed files with 20 additions and 0 deletions
|
@ -131,6 +131,26 @@ def store_endgame_actions(game_id: int, endgame_actions: List[EndgameAction]) ->
|
|||
conn.commit()
|
||||
|
||||
|
||||
def load_endgame_actions(game_id: int) -> List[EndgameAction]:
|
||||
cur = conn_manager.get_new_cursor()
|
||||
cur.execute(
|
||||
"SELECT (turn, action_type, suit_index, rank, enumerator, denominator) "
|
||||
"FROM endgames "
|
||||
"WHERE game_id = %s "
|
||||
"ORDER BY turn ASC, action_type ASC, suit_index ASC, rank ASC",
|
||||
(game_id,)
|
||||
)
|
||||
ret = []
|
||||
for (turn, action_type, suit_index, rank, enumerator, denominator) in cur.fetchall():
|
||||
ret.append(EndgameAction(
|
||||
turn,
|
||||
hanabi.hanab_game.ActionType(action_type),
|
||||
hanabi.hanab_game.DeckCard(suit_index, rank),
|
||||
enumerator, denominator)
|
||||
)
|
||||
return ret
|
||||
|
||||
|
||||
def parse_match(action: Dict) -> EndgameAction:
|
||||
turn = action["turn"]
|
||||
action_type = parse_action_type(action["type"])
|
||||
|
|
Loading…
Reference in a new issue