Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
avm99963 | 49fe619 | 2019-09-24 14:34:39 +0200 | [diff] [blame] | 3 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
Adrià Vilanova Martínez | dc7fbb6 | 2022-12-11 16:28:44 +0100 | [diff] [blame] | 4 | <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"> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 7 | <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 | |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 16 | $credentials = new Credentials(); |
Adrià Vilanova Martínez | 6052433 | 2022-11-20 02:33:56 +0100 | [diff] [blame] | 17 | $usersdb = $credentials->usersdb(); |
| 18 | $mortsdb = $credentials->mortsdb(); |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 19 | |
| 20 | // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200 |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 21 | $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"; |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 27 | |
| 28 | $results = query($getranking); |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 29 | // die($getranking); |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 30 | ?> |
| 31 | |
| 32 | <div id="outter-container"> |
| 33 | <div id="inner-container"> |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 34 | <header> |
| 35 | <div id="leftlinks"><a id="info" href="javascript:void(0);" onclick="js: toggleinfo();">+Info</a></div> |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 36 | <div id="rightlinks"><a href="./main.php">Tornar a la pàgina principal</a></div> |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 37 | </header> |
avm99963 | 49fe619 | 2019-09-24 14:34:39 +0200 | [diff] [blame] | 38 | |
Adrià Vilanova Martínez | 4861da6 | 2022-12-10 21:58:42 +0100 | [diff] [blame] | 39 | <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> |
avm99963 | 49fe619 | 2019-09-24 14:34:39 +0200 | [diff] [blame] | 40 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 41 | <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; |
avm99963 | 49fe619 | 2019-09-24 14:34:39 +0200 | [diff] [blame] | 55 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 56 | 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>"; |
avm99963 | 49fe619 | 2019-09-24 14:34:39 +0200 | [diff] [blame] | 62 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 63 | 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>"; |
avm99963 | 49fe619 | 2019-09-24 14:34:39 +0200 | [diff] [blame] | 74 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 75 | $i = $i + 1; |
| 76 | } |
| 77 | ?> |
| 78 | </table> |
| 79 | </div> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 80 | </div> |
| 81 | </div> |
| 82 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 83 | <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 | |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 97 | </body> |
| 98 | </html> |