include loss reasons and urls into table
This commit is contained in:
parent
b65c4fe43f
commit
87cbc700ee
1 changed files with 11 additions and 12 deletions
23
get_sheet.py
23
get_sheet.py
|
@ -89,13 +89,12 @@ def collect_player_games():
|
|||
|
||||
return global_games
|
||||
|
||||
def analyze_bdrs(games):
|
||||
def analyze_games(games):
|
||||
retval = {}
|
||||
for game_id in games.keys():
|
||||
game = get("export/" + str(game_id))
|
||||
bdrs = describe_game(game)
|
||||
print(game_id, bdrs)
|
||||
retval[game_id] = bdrs
|
||||
bdrs, termination = describe_game(game)
|
||||
retval[game_id] = bdrs, termination
|
||||
return retval
|
||||
|
||||
|
||||
|
@ -112,9 +111,9 @@ def sort_players_by_num_games(games_dict):
|
|||
|
||||
if __name__ == "__main__":
|
||||
games = collect_player_games()
|
||||
bdrs = analyze_bdrs(games)
|
||||
analysis = analyze_games(games)
|
||||
streaks = {}
|
||||
fieldnames = ['Replay Number', 'Link', 'Seed Name', 'Player #', 'W/L(1/0)', 'BDR']
|
||||
fieldnames = ['Replay Number', 'Seed Name', 'Player #', 'Result', 'BDR']
|
||||
fieldnames += sort_players_by_num_games(games)
|
||||
fieldnames += ['Other']
|
||||
|
||||
|
@ -124,13 +123,13 @@ if __name__ == "__main__":
|
|||
with open('games.csv', 'a', newline='') as f:
|
||||
writer = csv.DictWriter(f, fieldnames=fieldnames)
|
||||
for game_id, entry in sorted(games.items()):
|
||||
bdrs, termination = analysis[game_id]
|
||||
row = {
|
||||
'Replay Number': entry.game_id,
|
||||
'Link': 'https://hanab.live/replay/{}'.format(entry.game_id),
|
||||
'Seed Name': entry.seed,
|
||||
'Replay Number': "<a href='https://hanab.live/replay/{}'>{}</a>".format(entry.game_id, entry.game_id),
|
||||
'Seed Name': "<a href='https://hanab.live/seed/{}'>{}</a>".format(entry.seed, entry.seed),
|
||||
'Player #': entry.num_players,
|
||||
'W/L(1/0)': entry.won,
|
||||
'BDR': len(bdrs[game_id])
|
||||
'Result': 'Win' if entry.won else termination,
|
||||
'BDR': len(bdrs),
|
||||
}
|
||||
for player in entry.players:
|
||||
col = player_mapping.get(player, None)
|
||||
|
@ -148,4 +147,4 @@ if __name__ == "__main__":
|
|||
row['Other'] = num_others + 1
|
||||
writer.writerow(row)
|
||||
a = pandas.read_csv("games.csv")
|
||||
a.to_html("games.html")
|
||||
a.to_html("games.html", escape=False)
|
||||
|
|
Loading…
Reference in a new issue