blob: c682d647cbc2032b3dcf7ce6d6a50fbaafcac1dc [file] [log] [blame]
Andreu2211ab22019-09-23 18:13:26 +02001<html>
2<head>
avm9996349fe6192019-09-24 14:34:39 +02003 <meta name="viewport" content="width=device-width, initial-scale=1">
Andreu2211ab22019-09-23 18:13:26 +02004 <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
Andreu2211ab22019-09-23 18:13:26 +02005 <link rel="stylesheet" href="./css/ranking.css" />
6</head>
7
8<body>
9
10<?php
11 require './credentials.php';
12 require './php/utils.php';
13
Andreu20af6c22019-09-24 18:33:50 +020014 $credentials = new Credentials();
Adrià Vilanova Martínez60524332022-11-20 02:33:56 +010015 $usersdb = $credentials->usersdb();
16 $mortsdb = $credentials->mortsdb();
Andreu2211ab22019-09-23 18:13:26 +020017
18 // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200
Andreu20af6c22019-09-24 18:33:50 +020019 $getranking = "SELECT $mortsdb.assassi AS id, $usersdb.nom, $usersdb.grau, $usersdb.curs, count($mortsdb.assassi) AS kills,
20 sum($mortsdb.grau = $usersdb.grau AND $mortsdb.curs = $usersdb.curs) AS companys_classe,
21 sum($mortsdb.grau = $usersdb.grau AND $mortsdb.curs != $usersdb.curs) AS companys_grau,
22 sum($mortsdb.grau != $usersdb.grau) AS companys_facu,
23 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
24 FROM $mortsdb INNER JOIN $usersdb ON $mortsdb.assassi = $usersdb.id GROUP BY $mortsdb.assassi ORDER BY score DESC";
Andreu2211ab22019-09-23 18:13:26 +020025
26 $results = query($getranking);
Andreu20af6c22019-09-24 18:33:50 +020027 // die($getranking);
Andreu2211ab22019-09-23 18:13:26 +020028?>
29
30<div id="outter-container">
31 <div id="inner-container">
Andreuae44f202019-09-23 23:15:56 +020032 <header>
33 <div id="leftlinks"><a id="info" href="javascript:void(0);" onclick="js: toggleinfo();">+Info</a></div>
Andreu03d030d2019-09-25 21:52:01 +020034 <div id="rightlinks"><a href="./main.php">Tornar a la pàgina principal</a></div>
Andreuae44f202019-09-23 23:15:56 +020035 </header>
avm9996349fe6192019-09-24 14:34:39 +020036
Andreuae44f202019-09-23 23:15:56 +020037 <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>
avm9996349fe6192019-09-24 14:34:39 +020038
Andreuae44f202019-09-23 23:15:56 +020039 <div id="table-container">
40 <table id="ranking" cellspacing="0" cellpadding="0">
41 <tr id="header">
42 <th></th>
43 <th>Assassins</th>
44 <th>T</th>
45 <th>P</th>
46 <th>C</th>
47 <th>G</th>
48 <th>F</th>
49 </tr>
50 <?php
51 $id = 0;
52 $i = 1;
avm9996349fe6192019-09-24 14:34:39 +020053
Andreuae44f202019-09-23 23:15:56 +020054 while ($row = $results->fetch_object()) {
55 if ($i == 1) echo "<tr class='gold top3'>";
56 else if ($i == 2) echo "<tr class='silver top3'>";
57 else if ($i == 3) echo "<tr class='bronze top3'>";
58 else if ($row->id == $id) echo "<tr class='me'>";
59 else echo "<tr>";
avm9996349fe6192019-09-24 14:34:39 +020060
Andreuae44f202019-09-23 23:15:56 +020061 echo "<td>". ($i > 3 ? $i : '') ."</td>";
62 echo "<td class='name'><div>
63 <div class='username'>$row->nom</div>
64 <div class='userinfo'>".nomcurs($row->curs)." - ".nomgrau($row->grau)."</div>
65 </div></td>";
66 echo "<td>$row->kills</td>";
67 echo "<td><b>$row->score</b></td>";
68 echo "<td>$row->companys_classe</td>";
69 echo "<td>$row->companys_grau</td>";
70 echo "<td>$row->companys_facu</td>";
71 echo "</tr>";
avm9996349fe6192019-09-24 14:34:39 +020072
Andreuae44f202019-09-23 23:15:56 +020073 $i = $i + 1;
74 }
75 ?>
76 </table>
77 </div>
Andreu2211ab22019-09-23 18:13:26 +020078 </div>
79</div>
80
Andreuae44f202019-09-23 23:15:56 +020081<script>
82 function toggleinfo() {
83 let state = document.getElementsByTagName("p")[0].style.display;
84 if (state == "block") {
85 document.getElementsByTagName("p")[0].style.display = "none";
86 document.getElementsByTagName("a")[0].innerHTML = "+Info";
87 } else {
88 document.getElementsByTagName("p")[0].style.display = "block";
89 document.getElementsByTagName("a")[0].innerHTML = "-Info";
90 }
91 return false;
92 }
93</script>
94
Andreu2211ab22019-09-23 18:13:26 +020095</body>
96</html>