blob: 3d90f1dba0df0acbb53968de25afa3217f60c998 [file] [log] [blame]
Andreu2211ab22019-09-23 18:13:26 +02001<html>
2<head>
avm999636b62d652019-09-24 14:35:10 +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';
avm999636b62d652019-09-24 14:35:10 +020013
Andreu2211ab22019-09-23 18:13:26 +020014 // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi";
15 // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills, sum(CASE WHEN morts.grau = users.grau THEN 1 ELSE 2 END) AS kills_pondered FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY kills_pondered DESC";
16 // Mateix grau i curs => 1, Mateix grau diferent curs => 2, Diferent grau => 3
17 // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills, sum(CASE WHEN morts.grau = users.grau AND morts.curs = users.curs THEN 1 WHEN morts.grau = users.grau AND morts.curs != users.curs THEN 2 ELSE 3 END) AS kills_pondered FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY kills_pondered DESC";
avm999636b62d652019-09-24 14:35:10 +020018
Andreu2211ab22019-09-23 18:13:26 +020019 // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200
20 $getranking = "SELECT morts.assassi AS id, users.nom, users.grau, users.curs, count(morts.assassi) AS kills,
21 sum(morts.grau = users.grau AND morts.curs = users.curs) AS companys_classe,
22 sum(morts.grau = users.grau AND morts.curs != users.curs) AS companys_grau,
23 sum(morts.grau != users.grau) AS companys_facu,
24 sum(CASE WHEN morts.grau = users.grau AND morts.curs = users.curs THEN 100 WHEN morts.grau = users.grau AND morts.curs != users.curs THEN 150 ELSE 200 END) AS score
25 FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY score DESC";
avm999636b62d652019-09-24 14:35:10 +020026
Andreu2211ab22019-09-23 18:13:26 +020027 $results = query($getranking);
28?>
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>
34 <div id="rightlinks"><a href="./index.php">Tornar a l'inici</a></div>
35 </header>
avm999636b62d652019-09-24 14:35:10 +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>
avm999636b62d652019-09-24 14:35:10 +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;
avm999636b62d652019-09-24 14:35:10 +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>";
avm999636b62d652019-09-24 14:35:10 +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>";
avm999636b62d652019-09-24 14:35:10 +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>