blob: 8f2e557663ac344124d9969434fcd81d2ce723db [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">
Adrià Vilanova Martínezdc7fbb62022-12-11 16:28:44 +01004 <link rel="preconnect" href="https://fonts.googleapis.com">
5 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
6 <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,500;1,400;1,500" rel="stylesheet">
Andreu2211ab22019-09-23 18:13:26 +02007 <link rel="stylesheet" href="./css/ranking.css" />
8</head>
9
10<body>
11
12<?php
13 require './credentials.php';
14 require './php/utils.php';
15
Andreu20af6c22019-09-24 18:33:50 +020016 $credentials = new Credentials();
Adrià Vilanova Martínez60524332022-11-20 02:33:56 +010017 $usersdb = $credentials->usersdb();
18 $mortsdb = $credentials->mortsdb();
Andreu2211ab22019-09-23 18:13:26 +020019
20 // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200
Andreu20af6c22019-09-24 18:33:50 +020021 $getranking = "SELECT $mortsdb.assassi AS id, $usersdb.nom, $usersdb.grau, $usersdb.curs, count($mortsdb.assassi) AS kills,
22 sum($mortsdb.grau = $usersdb.grau AND $mortsdb.curs = $usersdb.curs) AS companys_classe,
23 sum($mortsdb.grau = $usersdb.grau AND $mortsdb.curs != $usersdb.curs) AS companys_grau,
24 sum($mortsdb.grau != $usersdb.grau) AS companys_facu,
25 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
26 FROM $mortsdb INNER JOIN $usersdb ON $mortsdb.assassi = $usersdb.id GROUP BY $mortsdb.assassi ORDER BY score DESC";
Andreu2211ab22019-09-23 18:13:26 +020027
28 $results = query($getranking);
Andreu20af6c22019-09-24 18:33:50 +020029 // die($getranking);
Andreu2211ab22019-09-23 18:13:26 +020030?>
31
32<div id="outter-container">
33 <div id="inner-container">
Andreuae44f202019-09-23 23:15:56 +020034 <header>
35 <div id="leftlinks"><a id="info" href="javascript:void(0);" onclick="js: toggleinfo();">+Info</a></div>
Andreu03d030d2019-09-25 21:52:01 +020036 <div id="rightlinks"><a href="./main.php">Tornar a la pàgina principal</a></div>
Andreuae44f202019-09-23 23:15:56 +020037 </header>
avm9996349fe6192019-09-24 14:34:39 +020038
Adrià Vilanova Martínez4861da62022-12-10 21:58:42 +010039 <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 any d'entrada i torn, mateix grau), companys de <b>g</b>rau (mateix grau) i companys de <b>f</b>acultat (diferents graus). Amb puntuacions +100, +150 i +200; respectivament.</p>
avm9996349fe6192019-09-24 14:34:39 +020040
Andreuae44f202019-09-23 23:15:56 +020041 <div id="table-container">
42 <table id="ranking" cellspacing="0" cellpadding="0">
43 <tr id="header">
44 <th></th>
45 <th>Assassins</th>
46 <th>T</th>
47 <th>P</th>
48 <th>C</th>
49 <th>G</th>
50 <th>F</th>
51 </tr>
52 <?php
53 $id = 0;
54 $i = 1;
avm9996349fe6192019-09-24 14:34:39 +020055
Andreuae44f202019-09-23 23:15:56 +020056 while ($row = $results->fetch_object()) {
57 if ($i == 1) echo "<tr class='gold top3'>";
58 else if ($i == 2) echo "<tr class='silver top3'>";
59 else if ($i == 3) echo "<tr class='bronze top3'>";
60 else if ($row->id == $id) echo "<tr class='me'>";
61 else echo "<tr>";
avm9996349fe6192019-09-24 14:34:39 +020062
Andreuae44f202019-09-23 23:15:56 +020063 echo "<td>". ($i > 3 ? $i : '') ."</td>";
64 echo "<td class='name'><div>
65 <div class='username'>$row->nom</div>
66 <div class='userinfo'>".nomcurs($row->curs)." - ".nomgrau($row->grau)."</div>
67 </div></td>";
68 echo "<td>$row->kills</td>";
69 echo "<td><b>$row->score</b></td>";
70 echo "<td>$row->companys_classe</td>";
71 echo "<td>$row->companys_grau</td>";
72 echo "<td>$row->companys_facu</td>";
73 echo "</tr>";
avm9996349fe6192019-09-24 14:34:39 +020074
Andreuae44f202019-09-23 23:15:56 +020075 $i = $i + 1;
76 }
77 ?>
78 </table>
79 </div>
Andreu2211ab22019-09-23 18:13:26 +020080 </div>
81</div>
82
Andreuae44f202019-09-23 23:15:56 +020083<script>
84 function toggleinfo() {
85 let state = document.getElementsByTagName("p")[0].style.display;
86 if (state == "block") {
87 document.getElementsByTagName("p")[0].style.display = "none";
88 document.getElementsByTagName("a")[0].innerHTML = "+Info";
89 } else {
90 document.getElementsByTagName("p")[0].style.display = "block";
91 document.getElementsByTagName("a")[0].innerHTML = "-Info";
92 }
93 return false;
94 }
95</script>
96
Andreu2211ab22019-09-23 18:13:26 +020097</body>
98</html>