blob: c9b2b96d9be95c1fb7c6fad83ef0df5e3faf08fc [file] [log] [blame]
Andreu2211ab22019-09-23 18:13:26 +02001<html>
2<head>
3 <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
Andreu2211ab22019-09-23 18:13:26 +02004 <link rel="stylesheet" href="./css/ranking.css" />
5</head>
6
7<body>
8
9<?php
10 require './credentials.php';
11 require './php/utils.php';
12
Andreu20af6c22019-09-24 18:33:50 +020013 $credentials = new Credentials();
14 $usersdb = $credentials->usersdb;
15 $mortsdb = $credentials->mortsdb;
Andreu2211ab22019-09-23 18:13:26 +020016
17 // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200
Andreu20af6c22019-09-24 18:33:50 +020018 $getranking = "SELECT $mortsdb.assassi AS id, $usersdb.nom, $usersdb.grau, $usersdb.curs, count($mortsdb.assassi) AS kills,
19 sum($mortsdb.grau = $usersdb.grau AND $mortsdb.curs = $usersdb.curs) AS companys_classe,
20 sum($mortsdb.grau = $usersdb.grau AND $mortsdb.curs != $usersdb.curs) AS companys_grau,
21 sum($mortsdb.grau != $usersdb.grau) AS companys_facu,
22 sum(CASE WHEN $mortsdb.grau = $usersdb.grau AND $mortsdb.curs = $usersdb.curs THEN 100 WHEN $mortsdb.grau = $usersdb.grau AND $mortsdb.curs != $usersdb.curs THEN 150 ELSE 200 END) AS score
23 FROM $mortsdb INNER JOIN $usersdb ON $mortsdb.assassi = $usersdb.id GROUP BY $mortsdb.assassi ORDER BY score DESC";
Andreu2211ab22019-09-23 18:13:26 +020024
25 $results = query($getranking);
Andreu20af6c22019-09-24 18:33:50 +020026 // die($getranking);
Andreu2211ab22019-09-23 18:13:26 +020027?>
28
29<div id="outter-container">
30 <div id="inner-container">
Andreuae44f202019-09-23 23:15:56 +020031 <header>
32 <div id="leftlinks"><a id="info" href="javascript:void(0);" onclick="js: toggleinfo();">+Info</a></div>
Andreu03d030d2019-09-25 21:52:01 +020033 <div id="rightlinks"><a href="./main.php">Tornar a la pàgina principal</a></div>
Andreuae44f202019-09-23 23:15:56 +020034 </header>
Andreu2211ab22019-09-23 18:13:26 +020035
Andreuae44f202019-09-23 23:15:56 +020036 <p><img src="./bin/images/info.png" width="32px" /> La puntuació de cada jugador es calcula com a una suma ponderada depenent del caràcter de les seves víctimes: companys de <b>c</b>lasse (mateix curs, mateix grau), companys de <b>g</b>rau (mateix grau) i companys de <b>f</b>acultat (diferents grau). Amb puntuacions +100, +150 i +200; respectivament.</p>
37
38 <div id="table-container">
39 <table id="ranking" cellspacing="0" cellpadding="0">
40 <tr id="header">
41 <th></th>
42 <th>Assassins</th>
43 <th>T</th>
44 <th>P</th>
45 <th>C</th>
46 <th>G</th>
47 <th>F</th>
48 </tr>
49 <?php
50 $id = 0;
51 $i = 1;
Andreu2211ab22019-09-23 18:13:26 +020052
Andreuae44f202019-09-23 23:15:56 +020053 while ($row = $results->fetch_object()) {
54 if ($i == 1) echo "<tr class='gold top3'>";
55 else if ($i == 2) echo "<tr class='silver top3'>";
56 else if ($i == 3) echo "<tr class='bronze top3'>";
57 else if ($row->id == $id) echo "<tr class='me'>";
58 else echo "<tr>";
59
60 echo "<td>". ($i > 3 ? $i : '') ."</td>";
61 echo "<td class='name'><div>
62 <div class='username'>$row->nom</div>
63 <div class='userinfo'>".nomcurs($row->curs)." - ".nomgrau($row->grau)."</div>
64 </div></td>";
65 echo "<td>$row->kills</td>";
66 echo "<td><b>$row->score</b></td>";
67 echo "<td>$row->companys_classe</td>";
68 echo "<td>$row->companys_grau</td>";
69 echo "<td>$row->companys_facu</td>";
70 echo "</tr>";
71
72 $i = $i + 1;
73 }
74 ?>
75 </table>
76 </div>
Andreu2211ab22019-09-23 18:13:26 +020077 </div>
78</div>
79
Andreuae44f202019-09-23 23:15:56 +020080<script>
81 function toggleinfo() {
82 let state = document.getElementsByTagName("p")[0].style.display;
83 if (state == "block") {
84 document.getElementsByTagName("p")[0].style.display = "none";
85 document.getElementsByTagName("a")[0].innerHTML = "+Info";
86 } else {
87 document.getElementsByTagName("p")[0].style.display = "block";
88 document.getElementsByTagName("a")[0].innerHTML = "-Info";
89 }
90 return false;
91 }
92</script>
93
Andreu2211ab22019-09-23 18:13:26 +020094</body>
95</html>