Skip to content

Commit

Permalink
Fixed issue with game name mismatch
Browse files Browse the repository at this point in the history
BGA has certain names for games in game creation that do not match what
they are called when the game is ongoing. For example, the name of a
table is sechsnimmt when the game is 6nimmt.

This commit adds an alias function to translate between the expected
name in game creation and the actual one used in the table json.
  • Loading branch information
pocc committed Dec 23, 2020
1 parent eaf3317 commit e725ffa
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/bga_table_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ async def get_tables_by_players(players, message, send_running_tables=True, game
table_player_ids = table["player_display"] # Table.player_display is the player Ids at this table
if set(bga_ids).issubset(table_player_ids):
# match the game if a game was specified
if len(game_target) == 0 or normalize_name(table["game_name"]) == normalize_name(game_target):
normalized_game_name = get_bga_alias(table["game_name"])
if len(game_target) == 0 or normalized_game_name == normalize_name(game_target):
player_tables.append(table)
for table in player_tables:
sent_messages += [await message.channel.send("Getting table information...")]
Expand Down Expand Up @@ -94,6 +95,19 @@ async def get_tables_by_players(players, message, send_running_tables=True, game
await bga_account.close_connection()


def get_bga_alias(game_name):
# BGA uses different names *in game* than for game creation, so recognize this.
aliases = {
"redsevengame": "red7",
"sechsnimmt": "6nimmt",
"sevenwonders": "7wonders",
"sevenwondersduel": "7wondersduel",
}
if normalize_name(game_name) in aliases:
return aliases[normalize_name(game_name)]
return normalize_name(game_name)


async def send_active_tables_list(message, bga_account, table, game_name):
# If a game has not started, but it is scheduled, it will be None here.
if table["gamestart"]:
Expand Down

0 comments on commit e725ffa

Please sign in to comment.