forked from Sleepcap/vDiplomacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hof.php
245 lines (203 loc) · 8.22 KB
/
hof.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
/*
Copyright (C) 2013 Oliver Auth
This file is part of vDiplomacy.
vDiplomacy is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
vDiplomacy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with vDiplomacy. If not, see <http://www.gnu.org/licenses/>.
*/
require_once('header.php');
require_once("lib/rating.php");
libHTML::starthtml();
print '<script type="text/javascript" src="contrib/tablekit/tablekit.js"></script>';
print libHTML::pageTitle('Hall of fame','The webDiplomacy hall of fame; the 100 highest ranking players on this server.');
print '<p align="center"><img src="images/points/vstack.png" alt=" "
title="webDiplomacy ranking points; who are the most skilled at gathering them from their foes?" /></p>';
print '<style type="text/css">
.sortcol {cursor: pointer; padding-right: 20px; background-repeat: no-repeat; background-position: right center; }
.sortasc {background-color: #DDFFAC; background-image: url(contrib/tablekit/up.gif); }
.sortdesc {background-color: #B9DDFF; background-image: url(contrib/tablekit/down.gif); }
.nosort { cursor: default;}
</style>';
print '<style type="text/css">
.cellg { border:1px solid #777; }
.cellb { border:1px solid #000; }
.points { width:16% ! important; border-right: solid #aaa 1px; }
</style>';
$alternate = false;
if(isset($_REQUEST['userID']))
{
$userID = (int)$_REQUEST['userID'];
$UserProfile = new User($userID);
print '<b>Stats for </b>'.$UserProfile->profile_link().':<br><br>';
print '<TABLE class="sortable">
<THEAD>
<TH class="cellb">Game</TH>
<TH class="cellb">Name</TH>
<TH class="cellb">Variant</TH>
<TH class="cellb">Status</TH>
<TH class="cellb">Change</TH>
<TH class="cellb">Total</TH>
</THEAD>';
$USER_TABL = $DB->sql_tabl("
SELECT r.rating, r.gameID, g.name, g.variantID, m.status FROM wD_Ratings r
LEFT JOIN wD_Games g ON (g.id = r.gameID)
LEFT JOIN wD_Members m ON (m.userID = r.userID && g.id=m.gameID)
WHERE r.ratingType='vDip'
&& r.userID=".$userID."
&& g.phase = 'Finished'
ORDER BY g.processTime ASC");
$rating_old = 1000;
while ( list($rating, $gameID, $gameName, $variantID, $status) = $DB->tabl_row($USER_TABL) )
{
print '
<tr class="replyalternate'.($alternate ? '1' : '2' ).'">
<TD class="cellg"><a href="hof.php?gameID='.$gameID.'">'.$gameID.'</a></TD>
<TD class="cellg"><a href="board.php?gameID='.$gameID.'">'.$gameName.'</TD>
<TD class="cellg"><a href="variants.php?variantID='.$variantID.'">'.Config::$variants[$variantID].'</TD>
<TD class="cellg">'.$status.'</TD>
<TD class="cellg">'.($rating - $rating_old).'</TD>
<TD class="cellg">'.$rating.'</TD>
</TR>';
$rating_old = $rating;
$alternate = !$alternate;
}
print '</TABLE>';
}
elseif(isset($_REQUEST['gameID']))
{
include_once ('gamepanel/game.php');
$gameID = (int)$_REQUEST['gameID'];
$Variant=libVariant::loadFromGameID($gameID);
$Game = $Variant->panelGame($gameID);
$Members = libRating::loadVDipMembers($Game);
$Members = libRating::calcVDipRating($Game, $Members);
print $Game->titleBar();
print '<br><TABLE class="sortable">
<THEAD>
<TH class="cellb">Player</TH>
<TH class="cellb">Rating</TH>
<TH class="cellb">Status</TH>
<TH class="cellb" align="right">Re Ø</TH>
<TH class="cellb" align="right">Rr Ø</TH>
<TH class="cellb" align="right">Ch</TH>
</THEAD>';
foreach ($Members as $userID => $Member)
{
$Re = $Rr = $gV = $mV = $Di = $Ch = 0 ;
foreach ($Member['matches'] as $results)
{
$Re += $results['Re'];
$Rr += $results['Rr'];
$Ch += $results['Ch'];
}
$Members[$userID]['Re'] = round ($Re / (count($Members) -1),2) * 100;
$Members[$userID]['Rr'] = round ($Rr / (count($Members) -1),2) * 100;
$Members[$userID]['Ch'] = round ($Ch);
}
foreach ($Members as $userID => $Member)
{
if ( $Member['Ch'] < 0) $col = '990002';
elseif ( $Member['Ch'] > 0) $col = '009902';
else $col = '000000';
print '
<tr class="replyalternate'.($alternate ? '1' : '2' ).'">
<TD class="cellg">'.$Member['name'].'</TD>
<TD class="cellg">'.$Member['rating'].' -> '.($Member['rating'] + $Member['Ch']).'</TD>
<TD class="cellg">'.$Member['status'].(($Member['SCr'] > 0 && $Member['status'] != 'Resigned') ? ' ('.$Member['SCr'].' SC)' : '').'</TD>
<TD class="cellg" align="right">'.$Member['Re'].'%</TD>
<TD class="cellg" align="right">'.$Member['Rr'].'%</TD>
<TD class="cellg" align="right"><font color="#'.$col.'"><B>'.$Member['Ch'].'</B></font></TD>
</TR>';
$alternate = !$alternate;
}
print '</TABLE><BR>';
foreach ($Members as $Member)
{
print '<TABLE class="sortable">
<THEAD>
<TH class="cellb">'.$Member['name'].' ('.$Member['status'].' / '.$Member['SCr'].'SCs / '.$Member['rating'].'->'.round($Member['rating'] + $Member['change']).')</TH>
<TH class="cellb" align="right">Re</TH>
<TH class="cellb" align="right">Rr</TH>
<TH class="cellb" align="right">Dif</TH>
<TH class="cellb" align="right">mV</TH>
<TH class="cellb" align="right">gV</TH>
<TH class="cellb" align="right">Ch</TH>
</THEAD>';
foreach ($Member['matches'] as $userID => $results)
{
if ($results['mV'] != 0)
{
if ( $results['Ch'] < 0) $col = '990002';
elseif ( $results['Ch'] > 0) $col = '009902';
else $col = '000000';
print '
<tr class="replyalternate'.($alternate ? '1' : '2' ).'">
<TD class="cellg">'.$Members[$userID]['name'].' ('.
$Members[$userID]['status'].
(($Members[$userID]['SCr'] > 0 && $Members[$userID]['status'] != 'Resigned') ? " / ".$Members[$userID]['SCr']. " SC " : "").
')</TD>
<TD class="cellg" align="right">'.(round($results['Re'],2)*100).'%</TD>
<TD class="cellg" align="right">'.(round($results['Rr'],2)*100).'%</TD>
<TD class="cellg" align="right"><font color="#'.$col.'">'.(round($results['Rr'] - $results['Re'],2)*100).'%</font></TD>
<TD class="cellg" align="right">'.(round($results['mV'],2)*100).'%</TD>
<TD class="cellg" align="right">'.round($results['gV'],2).'</TD>
<TD class="cellg" align="right"><font color="#'.$col.'">'.round($results['Ch'],2).'</font></TD>
</TR>';
$alternate = !$alternate;
}
}
if ( round($Member['change']) < 0) $col = '990002';
elseif ( round($Member['change']) > 0) $col = '009902';
else $col = '000000';
print ' <TFOOT>
<TR>
<TD colspan=6></TD>
<td class="replyalternate'.($alternate ? '1' : '2' ).' cellg" align="right"><font color="#'.$col.'"><b>'.round($Member['change']).'</b></font></TD>
</TR>
</TFOOT></TABLE><BR>';
}
}
else
{
print '<table class="credits">';
$alternate = false;
$i=1;
$VPOINTS_TABL = $DB->sql_tabl("
SELECT r.userID, u.username, r.rating FROM wD_Ratings r
LEFT JOIN wD_Users u ON (u.id = r.userID)
LEFT JOIN wD_Games g ON (g.id = r.gameID)
JOIN (SELECT MAX(g2.processTime) AS last, r2.userID AS uid FROM wD_Ratings r2
LEFT JOIN wD_Games g2 ON (g2.id = r2.gameID ) GROUP BY r2.userID) AS tab2 ON
(uid = r.userID && last = g.processTime)
WHERE r.ratingType='vDip'
&& u.type <> 'Banned'
ORDER BY r.rating DESC LIMIT 100");
while ( list($id, $username, $vPoints) = $DB->tabl_row($VPOINTS_TABL) )
{
$users[$id]['id'] = $id;
$users[$id]['name'] = $username;
$users[$id]['Vr'] = $vPoints;
$users[$id]['Vr#'] = $i;
$alternate = !$alternate;
print '
<tr class="replyalternate'.($alternate ? '1' : '2' ).'">
<td class="left points">
'.$vPoints.' '.libHTML::vpoints().' - #'.$i.'
</td>
<td class="right message"><a href="hof.php?userID='.$id.'">'.$username.'</a></td>
</tr>';
$i++;
}
print '</table>';
}
print '</div>';
libHTML::footer();
?>