Beispiel #1
0
 def _make_match_tables(self, ctx, user, matches):
     title = "{}'s Match History".format(user.name)
     headers = ["DATE", "ID", "DECK", "RESULT"]
     max_name_len = 15
     rows = []
     for match in matches:
         date = utils.short_date_from_timestamp(match['timestamp'])
         deck_name = utils.get_player_deck(user.id, match)
         deck_name = utils.shorten_deck_name(ctx, deck_name, maxlen=max_name_len)
         result = "WIN" if match['winner'] == user.id else "LOSE"
         rows.append([date, match['game_id'], deck_name, result])
     _line_table = line_table.LineTable(rows, title=title, headers=headers)
     return _line_table
Beispiel #2
0
def make_leaderboard_table(players, key, title):
    rows = []
    if key == "winrate":
        for i, player in enumerate(players):
            rows.append([
                f"{i+1}.", 
                player['name'], 
                f"{100*player['wins']/player['accepted']:.3g}%"])
    else:
        for i, player in enumerate(players):
            rows.append([f"{i+1}.", player['name'], str(player[key])])
    if not rows:
        return None
    return line_table.LineTable(rows, title=title)
Beispiel #3
0
    def _make_deck_tables(self, data, key):
        if key == "meta":
            title = "Deck Stats: Meta %"
            rows = [[f"{i+1}.", deck['name'], f"{100*deck[key]:.3g}%"]
                    for i, deck in enumerate(data)]
        elif key == "winloss":
            title = "Deck Stats: Win-Loss Ratio"
            rows = [[
                f"{i+1}.", deck['name'], f"{deck['wins']}-{deck['losses']}"
            ] for i, deck in enumerate(data)]
        elif key == "winrate":
            title = "Deck Stats: Win %"
            rows = [[f"{i+1}.", deck['name'], f"{100*deck[key]:.3g}%"]
                    for i, deck in enumerate(data)]
        elif key == "popularity":
            title = "Deck Stats: # of Pilots"
            rows = [[f"{i+1}.", deck['name'],
                     str(len(deck['players']))] for i, deck in enumerate(data)]

        return line_table.LineTable(rows, title=title)
Beispiel #4
0
 def _make_match_history_table(self, matches, deck_name):
     rows = [self._make_match_row(match, deck_name) for match in matches]
     return line_table.LineTable(rows).text[0]