From 3a58cb2802c8be14f78015105afe759b1c7ce692 Mon Sep 17 00:00:00 2001 From: Matthijs Kuiper Date: Tue, 9 Jan 2018 00:43:43 +0100 Subject: Implement design for pages and update includes --- html/includes/teamstats.php | 338 ++++++++++++++++++++++---------------------- 1 file changed, 166 insertions(+), 172 deletions(-) (limited to 'html/includes/teamstats.php') diff --git a/html/includes/teamstats.php b/html/includes/teamstats.php index b2116b9..d0b1b58 100755 --- a/html/includes/teamstats.php +++ b/html/includes/teamstats.php @@ -1,182 +1,176 @@ - - - '.htmlentities($title).' - '; - - $sql_players = "SELECT pi.name, pi.banned, p.pid, p.team, p.country, p.gametime, p.gamescore, p.frags, p.deaths, p.suicides, p.teamkills, p.eff, p.accuracy, p.ttl, p.rank".(($extra) ? ', p.'.$extra.' AS '.$extra : '')." - FROM uts_player AS p, uts_pinfo AS pi WHERE p.pid = pi.id AND matchid = $mid - ORDER BY".(($teams) ? ' team ASC,' : '')." $order"; - $q_players = mysql_query($sql_players) or die(mysql_error()); - $header = true; - teamstats_init_totals($totals, $num); - - while ($r_players = zero_out(mysql_fetch_array($q_players))) { - $r_players['dom_cp'] = $r_players['gamescore'] - $r_players['frags']; - $r_players['team'] = intval($r_players['team']); - - if ($teams and $oldteam != $r_players['team']) { - if ($r_players['team'] != 0) teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]); - $oldteam = $r_players['team']; - teamstats_init_totals($totals, $num, $extra); - - switch(intval($r_players['team'])) { - case 0: $teamname = 'Red'; break; - case 1: $teamname = 'Blue'; break; - case 2: $teamname = 'Green'; break; - case 3: $teamname = 'Gold'; break; - } - - echo'Team: '.$teamname.''; - $header = true; - } - - if ($header) { - $header = false; - echo ' - - Player - Time - Score'; - if ($extra) echo ''.htmlentities($extratitle).''; - echo' - F - K - D - S'; - if ($teams) echo 'TK'; - echo ' - Eff. - Acc. - Avg TTL - '; - } - - $eff = get_dp($r_players['eff']); - $acc = get_dp($r_players['accuracy']); - $ttl = GetMinutes($r_players['ttl']); - $kills = $r_players['frags'] + $r_players['suicides']; - $pname = $r_players['name']; - - $totals['gamescore'] += $r_players['gamescore']; - if ($extra) $totals[$extra] += $r_players[$extra]; - $totals['frags'] += $r_players['frags']; - $totals['kills'] += $kills; - $totals['deaths'] += $r_players['deaths']; - $totals['suicides'] += $r_players['suicides']; - $totals['teamkills'] += $r_players['teamkills']; - $totals['eff'] += $r_players['eff']; - $totals['acc'] += $r_players['accuracy']; - $totals['ttl'] += $r_players['ttl']; - $num++; - - if ($r_players['banned'] == 'Y') { - $eff = '-'; - $acc = '-'; - $ttl = '-'; - $kills = '-'; - $r_players['gamescore'] = '-'; - $r_players[$extra] = '-'; - $r_players['frags'] = '-'; - $r_players['deaths'] = '-'; - $r_players['suicides'] = '-'; - $r_players['teamkills'] = '-'; - } - - $class = ($num % 2) ? 'grey' : 'grey2'; - echo ''; - - if ($r_players['banned'] != 'Y') { - echo ''.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''; - } else { - echo ''.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''; - } - - echo ''.GetMinutes($r_players['gametime'] / TIMERATIO).''; - echo ''.$r_players['gamescore'].''; - - if ($extra) echo ''.$r_players[$extra].''; - - echo ''.$r_players['frags'].''; - echo ''.$kills.''; - echo ''.$r_players['deaths'].''; - echo ''.$r_players['suicides'].''; - - if ($teams) echo ''.$r_players['teamkills'].''; - - echo ''.$eff.''; - echo ''.$acc.''; - echo ''.$ttl.''; - echo ''; - } - - teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]); - - echo '
'; + global $gamename, $gid; + $r_info = small_query("SELECT teamgame, t0score, t1score, t2score, t3score FROM uts_match WHERE id = '$mid'"); + if (!$r_info) die("Match not found"); + + $teams = ($r_info['teamgame'] == 'True') ? true : false; + $teamscore[-1] = 0; + $teamscore[0] = $r_info['t0score']; + $teamscore[1] = $r_info['t1score']; + $teamscore[2] = $r_info['t2score']; + $teamscore[3] = $r_info['t3score']; + + $cols = 10; + if ($teams) $cols++; + if ($extra) $cols++; + + $oldteam = -1; + + echo' + + + + '; + + $sql_players = "SELECT pi.name, pi.banned, p.pid, p.team, p.country, p.gametime, p.gamescore, p.frags, p.deaths, p.suicides, p.teamkills, p.eff, p.accuracy, p.ttl, p.rank".(($extra) ? ', p.'.$extra.' AS '.$extra : '')." + FROM uts_player AS p, uts_pinfo AS pi WHERE p.pid = pi.id AND matchid = $mid + ORDER BY".(($teams) ? ' team ASC,' : '')." $order"; + $q_players = mysql_query($sql_players) or die(mysql_error()); + $header = true; + teamstats_init_totals($totals, $num); + + while ($r_players = zero_out(mysql_fetch_array($q_players))) { + $r_players['dom_cp'] = $r_players['gamescore'] - $r_players['frags']; + $r_players['team'] = intval($r_players['team']); + + if ($teams and $oldteam != $r_players['team']) { + if ($r_players['team'] != 0) teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]); + $oldteam = $r_players['team']; + teamstats_init_totals($totals, $num, $extra); + + switch(intval($r_players['team'])) { + case 0: $teamname = 'Red'; break; + case 1: $teamname = 'Blue'; break; + case 2: $teamname = 'Green'; break; + case 3: $teamname = 'Gold'; break; + } + + echo''; + $header = true; + } + if ($header) { + $header = false; + echo ' + + + + '; + if ($extra) echo ''; + echo ' + + + + '; + if ($teams) echo ''; + echo ' + + + + '; + } + + $eff = get_dp($r_players['eff']); + $acc = get_dp($r_players['accuracy']); + $ttl = GetMinutes($r_players['ttl']); + $kills = $r_players['frags'] + $r_players['suicides']; + $pname = $r_players['name']; + + $totals['gamescore'] += $r_players['gamescore']; + if ($extra) $totals[$extra] += $r_players[$extra]; + $totals['frags'] += $r_players['frags']; + $totals['kills'] += $kills; + $totals['deaths'] += $r_players['deaths']; + $totals['suicides'] += $r_players['suicides']; + $totals['teamkills'] += $r_players['teamkills']; + $totals['eff'] += $r_players['eff']; + $totals['acc'] += $r_players['accuracy']; + $totals['ttl'] += $r_players['ttl']; + $num++; + + if ($r_players['banned'] == 'Y') { + $eff = '-'; + $acc = '-'; + $ttl = '-'; + $kills = '-'; + $r_players['gamescore'] = '-'; + $r_players[$extra] = '-'; + $r_players['frags'] = '-'; + $r_players['deaths'] = '-'; + $r_players['suicides'] = '-'; + $r_players['teamkills'] = '-'; + } + + $class = ($num % 2) ? 'grey' : 'grey2'; + echo ''; + if ($r_players['banned'] != 'Y') { + echo ''; + } else { + echo ''; + } + echo ''; + echo ''; + + if ($extra) echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + + if ($teams) echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + } + + teamstats_team_totals($totals, $num, $teams, $extra, $teamscore[$oldteam]); + echo '
'.htmlentities($title).'
Team: '.$teamname.'
PlayerTimeScore'.htmlentities($extratitle).'FKDSTKEff.Acc.Avg TTL
'.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''.FormatPlayerName($r_players['country'], $r_players['pid'], $r_players['name'], $gid, $gamename, true, $r_players['rank']).''.GetMinutes($r_players['gametime'] / TIMERATIO).''.$r_players['gamescore'].''.$r_players[$extra].''.$r_players['frags'].''.$kills.''.$r_players['deaths'].''.$r_players['suicides'].''.$r_players['teamkills'].''.$eff.''.$acc.''.$ttl.'

'; } function teamstats_init_totals(&$totals, &$num, $extra = null) { - $totals['gamescore'] = 0; - if ($extra) $totals[$extra] = 0; - $totals['frags'] = 0; - $totals['kills'] = 0; - $totals['deaths'] = 0; - $totals['suicides'] = 0; - $totals['teamkills'] = 0; - $totals['eff'] = 0; - $totals['acc'] = 0; - $totals['ttl'] = 0; - $num = 0; + $totals['gamescore'] = 0; + if ($extra) $totals[$extra] = 0; + $totals['frags'] = 0; + $totals['kills'] = 0; + $totals['deaths'] = 0; + $totals['suicides'] = 0; + $totals['teamkills'] = 0; + $totals['eff'] = 0; + $totals['acc'] = 0; + $totals['ttl'] = 0; + $num = 0; } function teamstats_team_totals(&$totals, $num, $teams, $extra, $teamscore) { - if ($num == 0) $num = 1; - $eff = get_dp($totals['eff'] / $num); - $acc = get_dp($totals['acc'] / $num); - $ttl = GetMinutes($totals['ttl'] / $num); - - echo ''; - echo 'Totals'; - echo ''; - - if ($teams) { - echo ''.$teamscore.' ('.$totals[gamescore].')'; - } else { - echo ''.$totals[gamescore].''; - } - if ($extra) echo ''.$totals[$extra].''; - - echo ''.$totals[frags].''; - echo ''.$totals[kills].''; - echo ''.$totals[deaths].''; - echo ''.$totals[suicides].''; - - if ($teams) echo ''.$totals[teamkills].''; - - echo ''.$eff.''; - echo ''.$acc.''; - echo ''.$ttl.''; - echo ''; + if ($num == 0) $num = 1; + $eff = get_dp($totals['eff'] / $num); + $acc = get_dp($totals['acc'] / $num); + $ttl = GetMinutes($totals['ttl'] / $num); + + echo ''; + echo 'Totals'; + echo ''; + if ($teams) { + echo ''.$teamscore.' ('.$totals[gamescore].')'; + } else { + echo ''.$totals[gamescore].''; + } + if ($extra) echo ''.$totals[$extra].''; + + echo ''.$totals[frags].''; + echo ''.$totals[kills].''; + echo ''.$totals[deaths].''; + echo ''.$totals[suicides].''; + + if ($teams) echo ''.$totals[teamkills].''; + + echo ''.$eff.''; + echo ''.$acc.''; + echo ''.$ttl.''; + echo ''; } - ?> -- cgit