def matchinfo(self, ids): matches = self.dp.fetchmatchdata(ids) output = '' for mid in ids: match = Match.creatematch(mid, matches[mid]) output += match.matchstr(self.dp) + '\n' return output
def matchinfo(self, ids): matches = self.dp.fetchmatchdata(ids) tmpl_h, tmpl_f = Html.loadtemplates() output = tmpl_h.substitute() for mid in ids: match = Match.creatematch(mid, matches[mid]) legionplayers = match.players(team="legion") hellbourneplayers = match.players(team='hellbourne') output += '<h2>{mid}</h2>'.format(mid=mid) output += match.gamedatestr() + ' GD: ' + str(match.gameduration()) + '<br />\n' output += '<table cellspacing="0" cellpadding="2">' output += '<tr>' output += Html.list2cols(['Legion', 'Hero', 'LVL', 'K', 'D', 'A', 'CK', 'CD', 'W', 'GPM', 'GL2D', 'Hellbourne', 'Hero', 'LVL', 'K', 'D', 'A', 'CK', 'CD', 'W', 'GPM', 'GL2D'], 'th') legioncols = [] for id_ in legionplayers.keys(): legioncols.append([LinkItem('/player/{nick}'.format(nick=self.dp.id2nick(id_)), self.dp.id2nick(id_)), self.dp.heroid2name(match.playerstat(id_, 'hero_id')), match.playerstat(id_, 'level'), match.playerstat(id_, 'herokills'), match.playerstat(id_, 'deaths'), match.playerstat(id_, 'heroassists'), match.playerstat(id_, 'teamcreepkills') + match.playerstat(id_, 'neutralcreepkills'), match.playerstat(id_, 'denies'), match.playerstat(id_, 'wards'), int(match.playerstat(id_, 'gold') / (match.gameduration().total_seconds() / 60)), match.playerstat(id_, 'goldlost2death')]) hellcols = [] for id_ in hellbourneplayers.keys(): hellcols.append([LinkItem('/player/{nick}'.format(nick=self.dp.id2nick(id_)), self.dp.id2nick(id_)), self.dp.heroid2name(match.playerstat(id_, 'hero_id')), match.playerstat(id_, 'level'), match.playerstat(id_, 'herokills'), match.playerstat(id_, 'deaths'), match.playerstat(id_, 'heroassists'), match.playerstat(id_, 'teamcreepkills') + match.playerstat(id_, 'neutralcreepkills'), match.playerstat(id_, 'denies'), match.playerstat(id_, 'wards'), int(match.playerstat(id_, 'gold') / (match.gameduration().total_seconds() / 60)), match.playerstat(id_, 'goldlost2death')]) size = max(len(hellcols), len(legioncols)) for i in range(0, size): if i < len(legioncols): output += '<tr>' + Html.list2cols(legioncols[i] + hellcols[i]) + '</tr>' else: output += '<tr><td colspan="11"> </td>' + Html.list2cols(hellcols[i]) + '</tr>' output += '</tr>' output += '</table>' return output + tmpl_f.substitute()
def lastmatchesinfo(self, ids, statstype, hero, arglimit, count): output = '' for id_ in ids: id_hero = (id_, hero) if hero else None matchids = self.dp.matches(id_, statstype) limit = arglimit if (arglimit or count) < count else count matches = self.dp.fetchmatchdata(matchids, limit=limit, id_hero=id_hero) output += self.dp.id2nick(id_) + '\n' for mid in sorted(matches.keys(), reverse=True): match = Match.creatematch(mid, matches[mid]) output += match.matchstr(self.dp) + '\n' return output
def matchesinfo(self, ids, statstype, limit): tmpl_h, tmpl_f = Html.loadtemplates() output = tmpl_h.substitute() for id_ in ids: output += '<h2>{nick}</h2>'.format(nick=id_) output += '<table cellspacing="0" cellpadding="2">' output += '<tr>' + Html.list2cols(['MID', 'GT', 'GD', 'Date', 'K', 'D', 'A', 'KDR', 'Hero', 'WL', 'Wards', 'CK', 'CD', 'GPM'], 'th') + '</tr>' matchids = self.dp.matches(id_, statstype) avgdata = text.Text.initavgdata() limit = limit if limit else len(matchids) for i in range(limit): matches = self.dp.fetchmatchdata([matchids[i]]) match = Match.creatematch(matchids[i], matches[matchids[i]]) if isinstance(match, Match): matchdata = match.matchesdata(self.dp.nick2id(id_), self.dp) avgdata = text.Text.fillavgdata(avgdata, matchdata) rowdata = [LinkItem("/match/" + str(matchdata['mid']), matchdata['mid']), matchdata['gt'], matchdata['gd'], matchdata['date'], matchdata['k'], matchdata['d'], matchdata['a'], round(matchdata['kdr'], 2), matchdata['hero'], matchdata['wl'], matchdata['wa'], matchdata['ck'], matchdata['cd'], matchdata['gpm']] output += '<tr>' + Html.list2cols(rowdata) + '</tr>' output += '</table>' return output + tmpl_f.substitute()
def matchesinfo(self, ids, statstype, limit): output = '' for id_ in ids: matchids = self.dp.matches(id_, statstype) avgdata = Text.initavgdata() limit = min(limit, len(matchids)) if limit else len(matchids) output += self.dp.id2nick(id_) + '\n' output += Match.headermatches() + '\n' for i in range(limit): matches = self.dp.fetchmatchdata([matchids[i]]) match = Match.creatematch(matchids[i], matches[matchids[i]]) # count average if isinstance(match, Match): matchdata = match.matchesdata(self.dp.nick2id(id_), self.dp) avgdata = Text.fillavgdata(avgdata, matchdata) output += match.matchesstr(self.dp.nick2id(id_), self.dp) + '\n' avgdata = Text.finalizeavgdata(avgdata, limit) output += "average " + Match.MatchesFormat.format(**avgdata)[10:] + '\n' #print(json.dumps(history)) return output