]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
Link to the game for each cap record.
[xonotic/xonstat.git] / xonstat / templates / player_info.mako
1 <%inherit file="base.mako"/>
2 <%namespace name="nav" file="nav.mako" />
3 <%namespace file="accuracy.mako" import="accuracy" />
4
5 <%block name="navigation">
6 ${nav.nav('players')}
7 </%block>
8
9 <%block name="js">
10     % if player is not None:
11       <script src="/static/js/jquery-1.7.1.min.js"></script>
12       <script src="/static/js/jquery.flot.min.js"></script>
13       <script src="/static/js/bootstrap-tab.js"></script>
14       <script type="text/javascript">
15       $(function () {
16         $('#gbtab li').click(function(e) {
17             e.preventDefault();
18             $(this).tab('show');
19         })
20
21         $('#gbtab a:first').tab('show');
22       })
23       </script>
24
25       <script type="text/javascript">
26       $(function () {
27           // plot the accuracy graph
28           function plot_acc_graph(data) {
29               var games = new Array();
30               var avgs = new Array();
31               var accs = new Array();
32
33               var i=0;
34               for(i=0; i < data.games; i++) {
35                   avgs[i] = [i, data.avg];
36                   accs[i] = [i, data.accs[i][1]];
37                   game_link = '/game/' + data.accs[i][0];
38                   j = data.games - i;
39                   games[i] = [i, '<a href="' + game_link + '">' + j + '</a>'];
40               }
41
42               $.plot(
43                   $("#acc-graph"), 
44                   [ { label: 'average', data: avgs, hoverable: true, clickable: false }, 
45                     { label: 'accuracy', data: accs, lines: {show:true}, points: {show:false}, hoverable: true, clickable: true }, ],
46                   { yaxis: {ticks: 10, min: 0, max: 100 },
47                     xaxis: {ticks: games},
48                     grid: { hoverable: true, clickable: true },
49               });
50           }
51
52           // plot the damage graph
53           function plot_dmg_graph(data) {
54               var games = new Array();
55               var avgs = new Array();
56               var dmgs = new Array();
57
58               var i=0;
59               for(i=0; i < data.games; i++) {
60                   avgs[i] = [i, data.avg];
61                   dmgs[i] = [i, data.dmgs[i][1]];
62                   game_link = '/game/' + data.dmgs[i][0];
63                   j = data.games - i;
64                   games[i] = [i, '<a href="' + game_link + '">' + j + '</a>'];
65               }
66
67               $.plot(
68                   $("#dmg-graph"), 
69                   [ { label: 'average', data: avgs, hoverable: true, clickable: false }, 
70                     { label: 'efficiency', data: dmgs, lines: {show:true}, points: {show:false}, hoverable: true, clickable: true }, ],
71                   { yaxis: {ticks: 10, min: 0 },
72                     xaxis: {ticks: games},
73                     grid: { hoverable: true, clickable: true },
74               });
75           }
76
77           function showTooltip(x, y, contents) {
78             $('<div id="tooltip">' + contents + '</div>').css( {
79                 position: 'absolute',
80                 display: 'none',
81                 top: y - 35,
82                 left: x + 10,
83                 border: '1px solid #fdd',
84                 padding: '2px',
85                 'background-color': '#333333',
86                 opacity: 0.80
87             }).appendTo("body").fadeIn(200);
88           }
89
90           var previousPoint = null;
91           var previousLabel = null;
92           $('#acc-graph').bind("plothover", function (event, pos, item) {
93               if (item) {
94                 if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
95                     previousLabel = item.series.label;
96                     previousPoint = item.dataIndex;
97
98                     $("#tooltip").remove();
99                     var x = item.datapoint[0].toFixed(2),
100                         y = item.datapoint[1].toFixed(2);
101
102                     showTooltip(item.pageX, item.pageY, y + "%");
103                   }
104               }
105               else {
106                   $("#tooltip").remove();
107                   previousPoint = null;
108                   previousLabel = null;
109               }
110           });
111
112           $('#dmg-graph').bind("plothover", function (event, pos, item) {
113               if (item) {
114                 if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
115                     previousPoint = item.dataIndex;
116                     previousLabel = item.series.label;
117
118                     $("#tooltip").remove();
119                     var x = item.datapoint[0].toFixed(2),
120                         y = item.datapoint[1].toFixed(2);
121
122                     showTooltip(item.pageX, item.pageY, y);
123                   }
124               }
125               else {
126                   $("#tooltip").remove();
127                   previousPoint = null;
128                   previousLabel = null;
129               }
130           });
131
132           // bind click events to the weapon images
133           $(".acc-weap").click(function () {
134               var dataurl = $(this).find('a').attr('href');
135
136               $('.accuracy-nav').find('.weapon-active').removeClass('weapon-active');
137               $(this).addClass('weapon-active');
138
139               $.ajax({
140                   url: dataurl,
141                   method: 'GET',
142                   dataType: 'json',
143                   success: plot_acc_graph
144               });
145           });
146
147           $(".dmg-weap").click(function () {
148               var dataurl = $(this).find('a').attr('href');
149
150               $('.damage-nav').find('.weapon-active').removeClass('weapon-active');
151               $(this).addClass('weapon-active');
152
153               $.ajax({
154                   url: dataurl,
155                   method: 'GET',
156                   dataType: 'json',
157                   success: plot_dmg_graph
158               });
159           });
160
161           // populate the graphs with the default weapons
162           $.ajax({
163               url: '${request.route_url("player_accuracy", id=player.player_id)}',
164               method: 'GET',
165               dataType: 'json',
166               success: plot_acc_graph
167           });
168
169           $.ajax({
170               url: '${request.route_url("player_damage", id=player.player_id)}',
171               method: 'GET',
172               dataType: 'json',
173               success: plot_dmg_graph
174           });
175       })
176       </script>
177     % endif
178 </%block>
179
180 <%block name="title">
181 Player Information
182 </%block>
183
184
185 % if player is None:
186 <h2>This player is so good we couldn't find him!</h2>
187 <p>Seriously though, he probably doesn't exist...just a figment of your imagination. Carry on then!</p>
188
189 % else:
190 <div class="row">
191   <div class="span12">
192     <h2>${player.nick_html_colors()|n}</h2>
193   </div>
194 </div>
195
196 <div class="row">
197   <div id="gbtabcontainer" class="tabbable tabs-below">
198       <div class="tab-content">
199       % for g in games_played:
200         <div class="tab-pane fade in 
201         % if g.game_type_cd == 'overall':
202           active
203         % endif
204         " id="tab-${g.game_type_cd}">
205           <div class="span5">
206             <p>
207             % if g.game_type_cd in overall_stats:
208             Last Played: <small><span class="abstime" data-epoch="${overall_stats[g.game_type_cd].last_played_epoch}" title="${overall_stats[g.game_type_cd].last_played.strftime('%a, %d %b %Y %H:%M:%S UTC')}"> ${overall_stats[g.game_type_cd].last_played_fuzzy} </span> <br /></small>
209             % endif
210
211             Games Played: <small>${g.games} <br /></small>
212
213             Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
214
215             % if g.game_type_cd in fav_maps:
216             Favorite Map: <small>${fav_maps[g.game_type_cd].map_name} <br /></small>
217             % endif
218             </p>
219           </div>
220           <div class="span5">
221             <p>
222               Win Percentage: <small>${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br /></small>
223
224             % if g.game_type_cd in overall_stats:
225               % if overall_stats[g.game_type_cd].k_d_ratio is not None:
226               Kill Ratio: <small>${round(overall_stats[g.game_type_cd].k_d_ratio,2)} (${overall_stats[g.game_type_cd].total_kills} kills, ${overall_stats[g.game_type_cd].total_deaths} deaths) <br /></small>
227               % endif
228             % endif
229
230             % if g.game_type_cd in elos:
231               % if g.game_type_cd == 'overall':
232               Best Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].game_type_cd}, ${elos[g.game_type_cd].games} games) <br /></small>
233               % else:
234               Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
235               % endif
236             % endif
237
238             % if g.game_type_cd in ranks:
239               % if g.game_type_cd == 'overall':
240               Best Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (${ranks[g.game_type_cd].game_type_cd}, percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
241
242               % else:
243               Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
244               % endif
245             % endif
246
247             % if g.game_type_cd == 'ctf':
248               % if  overall_stats[g.game_type_cd].cap_ratio is not None:
249                 Cap Ratio: <small>${round(overall_stats[g.game_type_cd].cap_ratio,2)} (${overall_stats[g.game_type_cd].total_captures} captures, ${overall_stats[g.game_type_cd].total_pickups} pickups) <br /></small>
250               % endif
251             % endif
252             </p>
253           </div>
254         </div>
255       % endfor
256       </div>
257   </div>
258 </div>
259 <div class="row">
260   <div class="span12">
261       <ul id="gbtab" class="nav nav-tabs">
262       % for g in games_played:
263         <li>
264           <a href="#tab-${g.game_type_cd}" data-toggle="tab">
265             <img src="/static/images/icons/24x24/${g.game_type_cd}.png"> <br />
266             ${g.game_type_cd} <br />
267             <small>(${g.games})</small>
268           </a>
269         </li>
270       % endfor
271       </ul>
272   </div>
273 </div>
274
275
276 % if 'nex' in recent_weapons or 'rifle' in recent_weapons or 'minstanex' in recent_weapons or 'uzi' in recent_weapons or 'shotgun' in recent_weapons:
277 <div class="row">
278   <div class="span10">
279     <h3>Accuracy</h3>
280     <div id="acc-graph" class="flot" style="width:900px; height:200px;">
281     </div>
282
283     <div class="weapon-nav accuracy-nav">
284       <ul>
285         % if 'nex' in recent_weapons:
286         <li>
287           <div class="acc-weap weapon-active">
288             <img src="${request.static_url("xonstat:static/images/nex.png")}" />
289             <p><small>Nex</small></p>
290             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
291           </div>
292         </li>
293         % endif
294
295         % if 'rifle' in recent_weapons:
296         <li>
297           <div class="acc-weap">
298             <img src="${request.static_url("xonstat:static/images/rifle.png")}" />
299             <p><small>Rifle</small></p>
300             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
301           </div>
302         </li>
303         % endif
304
305         % if 'minstanex' in recent_weapons:
306         <li>
307           <div class="acc-weap">
308             <img src="${request.static_url("xonstat:static/images/minstanex.png")}" />
309             <p><small>Minstanex</small></p>
310             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
311           </div>
312         </li>
313         % endif
314
315         % if 'uzi' in recent_weapons:
316         <li>
317           <div class="acc-weap">
318             <img src="${request.static_url("xonstat:static/images/uzi.png")}" />
319             <p><small>Uzi</small></p>
320             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
321           </div>
322         </li>
323         % endif
324
325         % if 'shotgun' in recent_weapons:
326         <li>
327           <div class="acc-weap">
328             <img src="${request.static_url("xonstat:static/images/shotgun.png")}" />
329             <p><small>Shotgun</small></p>
330             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
331           </div>
332         </li>
333         % endif
334       </ul>
335     </div>
336
337   </div>
338 </div>
339 % endif
340
341
342 % if 'rocketlauncher' in recent_weapons or 'grenadelauncher' in recent_weapons or 'electro' in recent_weapons or 'crylink' in recent_weapons or 'laser' in recent_weapons:
343 <div class="row">
344   <div class="span10">
345     <h3>Damage Efficiency</h3>
346     <div id="dmg-graph" class="flot" style="width:900px; height:200px;">
347     </div>
348
349     <div class="weapon-nav damage-nav">
350       <ul>
351         % if 'rocketlauncher' in recent_weapons:
352         <li>
353           <div class="dmg-weap weapon-active">
354             <img src="${request.static_url("xonstat:static/images/rocketlauncher.png")}" />
355             <p><small>Rocket</small></p>
356             <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'rocketlauncher'})}" title="Show rocket launcher efficiency"></a>
357           </div>
358         </li>
359         % endif
360
361         % if 'grenadelauncher' in recent_weapons:
362         <li>
363           <div class="dmg-weap">
364             <img src="${request.static_url("xonstat:static/images/grenadelauncher.png")}" />
365             <p><small>Mortar</small></p>
366             <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'grenadelauncher'})}" title="Show mortar damage efficiency"></a>
367           </div>
368         </li>
369         % endif
370
371         % if 'electro' in recent_weapons:
372         <li>
373           <div class="dmg-weap">
374             <img src="${request.static_url("xonstat:static/images/electro.png")}" />
375             <p><small>Electro</small></p>
376             <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'electro'})}" title="Show electro damage efficiency"></a>
377           </div>
378         </li>
379         % endif
380
381         % if 'crylink' in recent_weapons:
382         <li>
383           <div class="dmg-weap">
384             <img src="${request.static_url("xonstat:static/images/crylink.png")}" />
385             <p><small>Crylink</small></p>
386             <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'crylink'})}" title="Show crylink damage efficiency"></a>
387           </div>
388         </li>
389         % endif
390
391         % if 'hagar' in recent_weapons:
392         <li>
393           <div class="dmg-weap">
394             <img src="${request.static_url("xonstat:static/images/hagar.png")}" />
395             <p><small>Hagar</small></p>
396             <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'hagar'})}" title="Show hagar damage efficiency"></a>
397           </div>
398         </li>
399         % endif
400
401         % if 'laser' in recent_weapons:
402         <li>
403           <div class="dmg-weap">
404             <img src="${request.static_url("xonstat:static/images/laser.png")}" />
405             <p><small>Laser</small></p>
406             <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'laser'})}" title="Show laser damage efficiency"></a>
407           </div>
408         </li>
409         % endif
410
411       </ul>
412     </div>
413
414   </div>
415 </div>
416 % endif
417
418
419 ##### RECENT GAMES (v2) ####
420 % if recent_games:
421 <div class="row">
422   <div class="span12">
423     <h3>Recent Games</h3>
424     <table class="table table-bordered table-condensed">
425       <thead>
426         <tr>
427            <th></th>
428            <th>Type</th>
429            <th>Server</th>
430            <th>Map</th>
431            <th>Result</th>
432            <th>Played</th>
433            <th>Elo</th>
434         </tr>
435       </thead>
436       <tbody>
437       % for (gamestat, game, server, map) in recent_games:
438         <tr>
439            <td class="tdcenter"><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=game.game_id)}" title="View detailed information about this game">view</a></td>
440            <td class="tdcenter"><img title="${game.game_type_cd}" src="/static/images/icons/24x24/${game.game_type_cd}.png" alt="${game.game_type_cd}" /></td>
441            <td>${server.name}</td>
442            <td>${map.name}</td>
443            <td>
444            % if gamestat.team != None:
445              % if gamestat.team == game.winner:
446              Win
447              % else:
448              Loss
449              % endif
450           % else:
451             % if gamestat.rank == 1:
452             Win
453             % else:
454             Loss (#${gamestat.rank})
455             % endif
456           % endif
457            </td>
458            <td><span class="abstime" data-epoch="${game.epoch()}" title="${game.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${game.fuzzy_date()}</span></td>
459            <td class="tdcenter">
460              % if gamestat.elo_delta is not None:
461                % if round(gamestat.elo_delta,2) > 0:
462                <span title="Elo went up by ${round(gamestat.elo_delta,2)}"><i class="icon-arrow-up icon-white"></i></span>
463                % elif round(gamestat.elo_delta,2) < 0:
464                <span title="Elo went down by ${round(gamestat.elo_delta,2)}"><i class="icon-arrow-down icon-white"></i></span>
465                % else:
466                <span title="Elo did not change"><i class="icon-minus icon-white"></i></span>
467                % endif
468              % else:
469                <span title="Elo did not change"><i class="icon-minus icon-white"></i></span>
470              % endif
471            </td>
472         </tr>
473       % endfor
474       </tbody>
475     </table>
476     % if total_games > 10:
477     <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.nick}">More games played by ${player.nick_html_colors()|n}...</a>
478     % endif
479   </div>
480 </div>
481 % endif
482 % endif