Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" /> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 4 | <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 | |
| 13 | // $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"; |
| 14 | // $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"; |
| 15 | // Mateix grau i curs => 1, Mateix grau diferent curs => 2, Diferent grau => 3 |
| 16 | // $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"; |
| 17 | |
| 18 | // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200 |
| 19 | $getranking = "SELECT morts.assassi AS id, users.nom, users.grau, users.curs, count(morts.assassi) AS kills, |
| 20 | sum(morts.grau = users.grau AND morts.curs = users.curs) AS companys_classe, |
| 21 | sum(morts.grau = users.grau AND morts.curs != users.curs) AS companys_grau, |
| 22 | sum(morts.grau != users.grau) AS companys_facu, |
| 23 | 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 |
| 24 | FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY score DESC"; |
| 25 | |
| 26 | $results = query($getranking); |
| 27 | ?> |
| 28 | |
| 29 | <div id="outter-container"> |
| 30 | <div id="inner-container"> |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame^] | 31 | <header> |
| 32 | <div id="leftlinks"><a id="info" href="javascript:void(0);" onclick="js: toggleinfo();">+Info</a></div> |
| 33 | <div id="rightlinks"><a href="./index.php">Tornar a l'inici</a></div> |
| 34 | </header> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 35 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame^] | 36 | <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; |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 52 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame^] | 53 | 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> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 77 | </div> |
| 78 | </div> |
| 79 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame^] | 80 | <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 | |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 94 | </body> |
| 95 | </html> |