Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a bug related to the final team score. Add the function to sort t…
…he stats.

	modified:   stats/page.php
	modified:   stats/parser.php
  • Loading branch information
Jean-Denis Caron committed Nov 24, 2012
1 parent 3e43def commit 0d50baa
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 82 deletions.
47 changes: 45 additions & 2 deletions stats/page.php
Expand Up @@ -25,11 +25,54 @@ function return_page ($contents, $nav, $rel) {
<link rel="stylesheet" type="text/css" href="{$path}global.css" media="screen">
<title>#tf2.pug.na on irc.gamesurge.net</title>
</head>
<script>
function sort(e, p){
a0 = new Array();
a1 = new Array();
b = '';
c = 0;
r = e.parentNode.parentNode;
n = e.innerHTML;
s0 = new Array();
s1 = new Array();
t = ''
while(r != null){
if(r.nodeName == "TR"){
if(c == 0){
t = '<tr>' + r.innerHTML + '</tr>';
}else{
a0.push({'p':p, 'r':r.innerHTML, 'v':r.childNodes[p].innerHTML.replace(',', '')});
a1.push(r.childNodes[p].innerHTML.replace(',', ''));
}
}
r = r.nextSibling;
c++;
}
b = a0.pop().r;
a1.pop();
a1.sort(function(x,y){return y-x});
content = '';
for(i = 0; i < a1.length; i++){
if(i % 2 == 0){
c1 = ' class=tr0';
}else{
c1 = ' class=tr1';
}
for(j = 0; j < a0.length; j++){
if(a1[i] == a0[j].v){
content += '<tr' + c1 + '>' + a0[j].r + '</tr>';
a0.splice(j, 1);
break;
}
}
}
e.parentNode.parentNode.parentNode.innerHTML = t + content + b;
}
</script>
<body>
<div id='container'>
<div class='main'>
<div class='topheader'><div style="position:absolute;right:28px;width:200px;"><a href="http://aigaming.com/" ><img style="text-decoration:none;border:0px" src="ai.gif"></a></div><form name="input" action="/" method="get"><input type="text" name="search" value="{$_REQUEST['search']}"/><input type="submit" value="Search" style="margin-left:20px;" /></form></div></a>
<div class='topheader'><form name="input" action="/" method="get"><input type="text" name="search" value="{$_REQUEST['search']}"/><input type="submit" value="Search" style="margin-left:20px;" /></form></div></a>
<div class='content1'>
{$contents}
</div>
Expand Down
89 changes: 9 additions & 80 deletions stats/parser.php
Expand Up @@ -505,11 +505,12 @@ function parse ($directory, $ready_word) {
// World triggered Round_Win
// example: World triggered "Round_Win" (winner "Red")
// ---------------------------------------------------------------------
else if (preg_match('/^World triggered "Round_Win"/',$event,$m)) {
else if (preg_match('/^Team "\w+" current score "(\d+)"/',$event,$m)) {
$score = $m[1];
if(preg_match('/Blue/',$event,$m)){
$blue_score++;
$blue_score = intval($score);
}else{
$red_score++;
$red_score = intval($score);
}
// Capture point resets
if (!is_array($c['list'])) { $c['list'] = array(); }
Expand Down Expand Up @@ -997,25 +998,7 @@ function parse ($directory, $ready_word) {
// -------------------------------------------------------------------------
// First two tables, main blue and main red
// -------------------------------------------------------------------------
$trh = <<<EOT
<tr>
<th width=80px>SteamId</th>
<th width=150px>Name</th>
<th width=100px>Classes</th>
<th>Points</th>
<th>Kills</th>
<th>Assists</th>
<th>Deaths</th>
<th>Caps</th>
<th>Caps<br>Blkd</th>
<th>Damage</th>
<th>Healed</th>
<th>Ubers</th>
<th>Built</th>
<th>Dmntns</th>
<th>Rvngs</th>
</tr>
EOT;
$trh = "<tr><th width=80px><a href='#' onclick='sort(this, 0)'>SteamID</a></th><th width=150px><a href='#' onclick='sort(this, 1)'>Name</a></th><th width=100px><a href='#' onclick='sort(this, 2)'>Classes</a></th><th><a href='#' onclick='sort(this, 3)'>Points</a></th><th><a href='#' onclick='sort(this, 4)'>Kills</a></th><th><a href='#' onclick='sort(this, 5)'>Assists</a></th><th><a href='#' onclick='sort(this, 6)'>Deaths</a></th><th><a href='#' onclick='sort(this, 7)'>Caps</a></th><th><a href='#' onclick='sort(this, 8)'>Caps<br>Blkd</a></th><th><a href='#' onclick='sort(this, 9)'>Damage</a></th><th><a href='#' onclick='sort(this, 10)'>Healed</a></th><th><a href='#' onclick='sort(this, 11)'>Ubers</a></th><th><a href='#' onclick='sort(this, 12)'>Builts</a></th><th><a href='#' onclick='sort(this, 13)'>Dmntns</a></th><th><a href='#' onclick='sort(this, 14)'>Rvngs</a></th></tr>";

if ($clanbattle) { $tmpstr = '- '; }
$blue = "<div class='breadcrumbs' style=\"font-size:15px;\">Download the demo file of this game : <a href='http://demos.atf2.org/{$tvFileName}'>{$tvFileName}</a></div>";
Expand All @@ -1029,25 +1012,7 @@ function parse ($directory, $ready_word) {
$tmpa['mod'] = $tmpa[$p[$id]['team']['team']]++ % 2;
$p[$id]['roles']['all']['damage'] = number_format($p[$id]['roles']['all']['damage']);
$p[$id]['roles']['all']['healed'] = number_format($p[$id]['roles']['all']['healed']);
$tr = <<<EOT
<tr class="tr{$tmpa['mod']}">
<td>$id</th>
<td><a href="{$p[$id]['html']}.html">{$p[$id]['alias']}</a></th>
<td>{$p[$id]['role']['str']}</th>
<td>{$p[$id]['roles']['all']['points']}</th>
<td>{$p[$id]['roles']['all']['kills']}</th>
<td>{$p[$id]['roles']['all']['assists']}</th>
<td>{$p[$id]['roles']['all']['deaths']}</th>
<td>{$p[$id]['roles']['all']['caps']}</th>
<td>{$p[$id]['roles']['all']['capturesblocked']}</th>
<td>{$p[$id]['roles']['all']['damage']}</th>
<td>{$p[$id]['roles']['all']['healed']}</th>
<td>{$p[$id]['roles']['all']['ubers']}</th>
<td>{$p[$id]['roles']['all']['builtobjects']}</th>
<td>{$p[$id]['roles']['all']['dominations']}</th>
<td>{$p[$id]['roles']['all']['revenges']}</th>
</tr>
EOT;
$tr = "<tr class=\"tr{$tmpa['mod']}\"><td>$id</th><td><a href=\"{$p[$id]['html']}.html\">{$p[$id]['alias']}</a></th><td>{$p[$id]['role']['str']}</th><td>{$p[$id]['roles']['all']['points']}</th><td>{$p[$id]['roles']['all']['kills']}</th><td>{$p[$id]['roles']['all']['assists']}</th><td>{$p[$id]['roles']['all']['deaths']}</th><td>{$p[$id]['roles']['all']['caps']}</th><td>{$p[$id]['roles']['all']['capturesblocked']}</th><td>{$p[$id]['roles']['all']['damage']}</th><td>{$p[$id]['roles']['all']['healed']}</th><td>{$p[$id]['roles']['all']['ubers']}</th><td>{$p[$id]['roles']['all']['builtobjects']}</th><td>{$p[$id]['roles']['all']['dominations']}</th><td>{$p[$id]['roles']['all']['revenges']}</th></tr>";
if($p[$id]['roles'][$role]['points'] > 0){
if (!strcmp($p[$id]['team']['team'],'Red')) { $red .= $tr; }
else if (!strcmp($p[$id]['team']['team'],'Blue')) { $blue .= $tr; }
Expand All @@ -1058,25 +1023,7 @@ function parse ($directory, $ready_word) {
foreach ($totals as $tteam => $row) {
$row['damage'] = number_format($row['damage']);
$row['healed'] = number_format($row['healed']);
$ttr = <<<EOT
<tr class="tr3">
<td>&nbsp;</td>
<td><b>Totals</b></td>
<td>&nbsp;</td>
<td>{$row['points']}&nbsp;</td>
<td>{$row['kills']}&nbsp;</td>
<td>{$row['assists']}&nbsp;</td>
<td>{$row['deaths']}&nbsp;</td>
<td>{$row['caps']}&nbsp;</td>
<td>{$row['capturesblocked']}&nbsp;</td>
<td>{$row['damage']}&nbsp;</td>
<td>{$row['healed']}&nbsp;</td>
<td>{$row['ubers']}&nbsp;</td>
<td>{$row['builtobjects']}&nbsp;</td>
<td>{$row['dominations']}&nbsp;</td>
<td>{$row['revenges']}&nbsp;</td>
</tr>
EOT;
$ttr = "<tr class=\"tr3\"><td>&nbsp;</td><td><b>Totals</b></td><td>&nbsp;</td><td>{$row['points']}&nbsp;</td><td>{$row['kills']}&nbsp;</td><td>{$row['assists']}&nbsp;</td><td>{$row['deaths']}&nbsp;</td><td>{$row['caps']}&nbsp;</td><td>{$row['capturesblocked']}&nbsp;</td><td>{$row['damage']}&nbsp;</td><td>{$row['healed']}&nbsp;</td><td>{$row['ubers']}&nbsp;</td><td>{$row['builtobjects']}&nbsp;</td><td>{$row['dominations']}&nbsp;</td><td>{$row['revenges']}&nbsp;</td></tr>";
if (!strcmp($tteam,'Blue')) { $blue .= $ttr; }
else if (!strcmp($tteam,'Red')) { $red .= $ttr; }
}
Expand All @@ -1087,16 +1034,7 @@ function parse ($directory, $ready_word) {
// -------------------------------------------------------------------------
// Main weapons table
// -------------------------------------------------------------------------
$trh = <<<EOT
<tr>
<th width=130px>Weapon</th>
<th width=50px>Total<br>Kills</th>
<th width=50px>Red<br>Kills</th>
<th width=50px>Blue<br>Kills</th>
<th>Biggest Killer</th>
<th width=50px>%<br>Total</th>
</tr>
EOT;
$trh = "<tr><th width=130px>Weapon</th><th width=50px>Total<br>Kills</th><th width=50px>Red<br>Kills</th><th width=50px>Blue<br>Kills</th><th>Biggest Killer</th><th width=50px>%<br>Total</th></tr>";

$weap = "<div class='contentheader3'>Weapons</div><table class='maintable'>{$trh}";

Expand All @@ -1106,16 +1044,7 @@ function parse ($directory, $ready_word) {
if (!strcmp($weapon,'all')) { continue; }
$tmp = $i++ % 2;
$percent = round($row['all']['kills'] * 100 / $weapons['all']['all']['kills']);
$tr = <<<EOT
<tr class="tr{$tmp}">
<td>{$weapon}</td>
<td>{$row['all']['kills']}</td>
<td>{$row['Red']['kills']}</td>
<td>{$row['Blue']['kills']}</td>
<td class="line{$row['all']['max_team']}"><a href="{$p[$row['all']['max_killer']]['html']}.html">{$p[$row['all']['max_killer']]['alias']}</a> - {$row['all']['max_kills']}</td>
<td>{$percent}</td>
</tr>
EOT;
$tr = "<tr class=\"tr{$tmp}\"><td>{$weapon}</td><td>{$row['all']['kills']}</td><td>{$row['Red']['kills']}</td><td>{$row['Blue']['kills']}</td><td class=\"line{$row['all']['max_team']}\"><a href=\"{$p[$row['all']['max_killer']]['html']}.html\">{$p[$row['all']['max_killer']]['alias']}</a> - {$row['all']['max_kills']}</td><td>{$percent}</td></tr>";
$weap .= $tr;
}

Expand Down

0 comments on commit 0d50baa

Please sign in to comment.