Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
avm99963 | 6b62d65 | 2019-09-24 14:35:10 +0200 | [diff] [blame] | 3 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 4 | <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] | 5 | <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 | |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 14 | $credentials = new Credentials(); |
| 15 | $usersdb = $credentials->usersdb; |
| 16 | $mortsdb = $credentials->mortsdb; |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 17 | |
| 18 | // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200 |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 19 | $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"; |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 25 | |
| 26 | $results = query($getranking); |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 27 | // die($getranking); |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 28 | ?> |
| 29 | |
| 30 | <div id="outter-container"> |
| 31 | <div id="inner-container"> |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 32 | <header> |
| 33 | <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] | 34 | <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] | 35 | </header> |
avm99963 | 6b62d65 | 2019-09-24 14:35:10 +0200 | [diff] [blame] | 36 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 37 | <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> |
avm99963 | 6b62d65 | 2019-09-24 14:35:10 +0200 | [diff] [blame] | 38 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 39 | <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; |
avm99963 | 6b62d65 | 2019-09-24 14:35:10 +0200 | [diff] [blame] | 53 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 54 | 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>"; |
avm99963 | 6b62d65 | 2019-09-24 14:35:10 +0200 | [diff] [blame] | 60 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 61 | 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>"; |
avm99963 | 6b62d65 | 2019-09-24 14:35:10 +0200 | [diff] [blame] | 72 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 73 | $i = $i + 1; |
| 74 | } |
| 75 | ?> |
| 76 | </table> |
| 77 | </div> |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 78 | </div> |
| 79 | </div> |
| 80 | |
Andreu | ae44f20 | 2019-09-23 23:15:56 +0200 | [diff] [blame] | 81 | <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 | |
Andreu | 2211ab2 | 2019-09-23 18:13:26 +0200 | [diff] [blame] | 95 | </body> |
| 96 | </html> |