runes.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <?php
  2. /**
  3. * Runes view.
  4. *
  5. * Contains the view layout and ome code to present the data.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. * @category View
  11. * @property Runes_Page $page The page model.
  12. * @var Runes_Page $page The page model.
  13. */
  14. ?>
  15. <!DOCTYPE html>
  16. <html lang='en'>
  17. <head>
  18. <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
  19. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
  20. <title><?=$page->get_title()?></title>
  21. <link rel='shortcut icon' href='<?=$page->get_favicon()?>'/>
  22. <!-- CSS files -->
  23. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
  24. <?php
  25. if (get_context()->get_game_mode() == GAME_MODE_ID::RTA){
  26. ?>
  27. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui-rta.css'/>
  28. <?php
  29. }
  30. ?>
  31. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>runes.css'/>
  32. <!-- Meta tags -->
  33. <link rel='canonical' href='<?=$page->get_canonical()?>'/>
  34. <link rel='author' href='<?=$page->get_author()?>'/>
  35. <link rel='publisher' href='<?=$page->get_author()?>'/>
  36. <meta name='description' content='<?=$page->get_description()?>'/>
  37. <meta property='og:title' content='<?=$page->get_title()?>'/>
  38. <meta property='og:url' content='<?=$page->get_canonical()?>'/>
  39. <meta property='og:description' content='<?=$page->get_description()?>'/>
  40. <meta property='og:image' content='<?=$page->get_icon()?>'/>
  41. <meta property='og:site_name' content='<?=$page->get_name()?>?>'/>
  42. <meta property='og:type' content='website'/>
  43. <meta property='og:locale' content='en'/>
  44. <meta name='twitter:card' content='summary'/>
  45. <meta name='twitter:title' content='<?=$page->get_title()?>'/>
  46. <meta name='twitter:description' content='<?=$page->get_description()?>'/>
  47. <meta name='twitter:image' content='<?=$page->get_icon()?>'/>
  48. <meta name='twitter:url' content='<?=$page->get_canonical()?>'/>
  49. <meta name='robots' content='index follow'/>
  50. <script>
  51. /**
  52. * Hack to treat all type selects as one.
  53. *
  54. * @param clicked Numeric order of the select clicked.
  55. * @param event onMouseDown event.
  56. */
  57. function fixTypeSelect(clicked, event){
  58. if (!event.ctrlKey){
  59. // If controll was not being held, clean all other selects
  60. const selects = document.querySelectorAll('.select_type');
  61. Array.from(selects).forEach((element, index) => {
  62. if (element.id != "select_type_" + clicked){
  63. element.selectedIndex = -1;
  64. }
  65. });
  66. }
  67. }
  68. /**
  69. * Hack to treat all main stat selects as one.
  70. *
  71. * @param clicked Numeric order of the select clicked.
  72. * @param event onMouseDown event.
  73. */
  74. function fixMainSelect(clicked, event){
  75. if (!event.ctrlKey){
  76. // If controll was not being held, clean all other selects
  77. const selects = document.querySelectorAll('.select_main');
  78. Array.from(selects).forEach((element, index) => {
  79. if (element.id != "select_main_" + clicked){
  80. element.selectedIndex = -1;
  81. }
  82. });
  83. }
  84. }
  85. /**
  86. * Hack to treat all sub stat selects as one.
  87. *
  88. * @param clicked Numeric order of the select clicked.
  89. * @param event onMouseDown event.
  90. */
  91. function fixSubSelect(clicked, event){
  92. if (!event.ctrlKey){
  93. // If controll was not being held, clean all other selects
  94. const selects = document.querySelectorAll('.select_sub');
  95. Array.from(selects).forEach((element, index) => {
  96. if (element.id != "select_sub_" + clicked){
  97. element.selectedIndex = -1;
  98. }
  99. });
  100. }
  101. }
  102. </script>
  103. </head>
  104. <body>
  105. <?php
  106. include __DIR__ . "/inc/header.php";
  107. ?>
  108. <aside class='content filters' id='filters'>
  109. <h2 id='filters_title'>
  110. Rune filters
  111. </h2>
  112. <p>
  113. Manage your runes
  114. </p>
  115. <form action='/<?=get_context()->get_player()->get_id()?>/runes/' method='get' id='filter_runes' class='filter'>
  116. <table>
  117. <tr>
  118. <td class='label' >
  119. Stars:
  120. </td>
  121. <td>
  122. <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=$page->get_filter("MIN_STARS")?>'/>
  123. -
  124. <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=$page->get_filter("MAX_STARS")?>'/>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td class='label'>
  129. Quality:
  130. </td>
  131. <td>
  132. <?php
  133. $selected = Array("", "", "", "", "");
  134. $selected[$page->get_filter("MIN_QUALITY") - 1] = "selected";
  135. ?>
  136. <select name='min_quality' id='filter_quality_min'>
  137. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  138. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  139. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  140. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  141. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  142. </select>
  143. -
  144. <?php
  145. $selected = Array("", "", "", "", "");
  146. $selected[$page->get_filter("MAX_QUALITY") - 1] = "selected";
  147. ?>
  148. <select name='max_quality' id='filter_quality_max'>
  149. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  150. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  151. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  152. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  153. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  154. </select>
  155. </td>
  156. </tr>
  157. <tr>
  158. <td class='label'>
  159. O. quality:
  160. </td>
  161. <td>
  162. <?php
  163. $selected = Array("", "", "", "", "");
  164. $selected[$page->get_filter("MIN_ORIGINAL_QUALITY") - 1] = "selected";
  165. ?>
  166. <select name='min_original_quality' id='filter_original_quality_min'>
  167. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  168. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  169. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  170. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  171. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  172. </select>
  173. -
  174. <?php
  175. $selected = Array("", "", "", "", "");
  176. $selected[$page->get_filter("MAX_ORIGINAL_QUALITY") - 1] = "selected";
  177. ?>
  178. <select name='max_original_quality' id='filter_original_quality_max'>
  179. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  180. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  181. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  182. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  183. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  184. </select>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td class='label'>
  189. Level:
  190. </td>
  191. <td>
  192. <input type='number' name='min_level' id='filter_level_min' min='0' max='15' value='<?=$page->get_filter("MIN_LEVEL")?>'/>
  193. -
  194. <input type='number' name='max_level' id='filter_level_max' min='0' max='15' value='<?=$page->get_filter("MAX_LEVEL")?>'/>
  195. </td>
  196. </tr>
  197. <tr>
  198. <td class='label'>
  199. Efficiency:
  200. </td>
  201. <td>
  202. <input type='number' name='min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$page->get_filter("MIN_EFFICIENCY")?>'/>%
  203. -
  204. <input type='number' name='max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$page->get_filter("MAX_EFFICIENCY")?>'/>%
  205. </td>
  206. </tr>
  207. <tr>
  208. <td class='label'>
  209. Max. eff.:
  210. </td>
  211. <td>
  212. <input type='number' name='min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$page->get_filter("MIN_MAX_EFFICIENCY")?>'/>%
  213. -
  214. <input type='number' name='max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$page->get_filter("MAX_MAX_EFFICIENCY")?>'/>%
  215. </td>
  216. </tr>
  217. <tr>
  218. <td class='label'>
  219. Main stat:
  220. </td>
  221. <td class='stats'>
  222. <div>
  223. <select multiple name='main_stat[]' class='select_main' id='filter_main_stat_0' onMouseDown='fixMainSelect(0, event);'>
  224. <?php
  225. $i = 0;
  226. $j = 1;
  227. $reflect = new ReflectionClass("RUNE_STAT_ID");
  228. foreach($reflect->getConstants() as $name => $id){
  229. $selected = "";
  230. if (in_array($id, $page->get_filter("MAIN"))){
  231. $selected = "selected='selected'";
  232. }
  233. $name_format = ucwords(str_replace("_P", "%", $name));
  234. ?>
  235. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  236. <?php
  237. if (($i + 1) % 2 == 0){
  238. ?>
  239. </select><select multiple name='main_stat[]' class='select_main' id='filter_main_stat_<?=$j?>' onMouseDown='fixMainSelect(<?=$j?>, event);'>
  240. <?php
  241. $j ++;
  242. }
  243. $i ++;
  244. }
  245. ?>
  246. </select>
  247. </div>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td class='label'>
  252. Sub stats:
  253. </td>
  254. <td class='stats'>
  255. <div>
  256. <select multiple name='sub_stat[]' class='select_sub' id='filter_sub_stat' onMouseDown='fixSubSelect(0, event);'>
  257. <?php
  258. $reflect = new ReflectionClass("RUNE_STAT_ID");
  259. $i = 0;
  260. $j = 1;
  261. foreach($reflect->getConstants() as $name => $id){
  262. $selected = "";
  263. if (in_array($id, $page->get_filter("SUB"))){
  264. $selected = "selected='selected'";
  265. }
  266. $name_format = ucwords(str_replace("_P", "%", $name));
  267. ?>
  268. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  269. <?php
  270. if (($i + 1) % 2 == 0){
  271. ?>
  272. </select><select multiple name='sub_stat[]' class='select_sub' id='filter_sub_stat_<?=$j?>' onMouseDown='fixSubSelect(<?=$j?>, event);'>
  273. <?php
  274. $j ++;
  275. }
  276. $i ++;
  277. }
  278. ?>
  279. </select>
  280. </div>
  281. </td>
  282. </tr>
  283. <tr>
  284. <td class='label'>
  285. Type:
  286. </td>
  287. <td class='type'>
  288. <div>
  289. <select multiple name='type[]' class='select_type' id='select_type_0' onMouseDown='fixTypeSelect(0, event);'>
  290. <?php
  291. $reflect = new ReflectionClass("RUNE_SET_ID");
  292. $i = 0;
  293. $j = 1;
  294. foreach($reflect->getConstants() as $name => $id){
  295. $selected = "";
  296. if (in_array($id, $page->get_filter("TYPE"))){
  297. $selected = "selected='selected'";
  298. }
  299. $name_format = ucwords(strtolower($name));
  300. if (strlen($name_format) > 9){
  301. $name_format = substr($name_format, 0, 9) . ".";
  302. }
  303. ?>
  304. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  305. <?php
  306. if (($i + 1) % 6 == 0 && ($i + 1) < sizeof($reflect->getConstants())){
  307. ?>
  308. </select><select multiple name='type[]' class='select_type' id='select_type_<?=$j?>' onMouseDown='fixTypeSelect(<?=$j?>, event);'>
  309. <?php
  310. $j ++;
  311. }
  312. $i ++;
  313. }
  314. ?>
  315. </select>
  316. </div>
  317. </td>
  318. </tr>
  319. <tr>
  320. <td class='label'>
  321. Slot:
  322. </td>
  323. <td class='slot'>
  324. <select multiple name='slot[]' id='filter_slot'>
  325. <?php
  326. for ($i = 1; $i <= 6; $i ++){
  327. if (in_array($i, $page->get_filter("SLOT"))){
  328. $selected = "selected='selected'";
  329. }
  330. else{
  331. $selected = "";
  332. }
  333. ?>
  334. <option value='<?=$i?>' <?=$selected?>><?=$i?></option>
  335. <?php
  336. }
  337. ?>
  338. </select>
  339. </td>
  340. </tr>
  341. <tr>
  342. <td class='label'>
  343. Assigned:
  344. </td>
  345. <td>
  346. <?php
  347. $selected = Array("", "", "", "", "");
  348. $selected[$page->get_filter("ASSIGNED")] = "selected";
  349. ?>
  350. <select name='assigned' id='filter_assigned'>
  351. <option value='0' <?=$selected[0]?>>All</option>
  352. <option value='1' <?=$selected[1]?>>Assigned</option>
  353. <option value='2' <?=$selected[2]?>>Unassigned</option>
  354. <option value='3' <?=$selected[3]?>>All (no storage)</option>
  355. <option value='4' <?=$selected[4]?>>Assigned (no storage)</option>
  356. </select>
  357. </td>
  358. </tr>
  359. <tr>
  360. <td class='filter'>
  361. Group by:
  362. </td>
  363. <td>
  364. <?php
  365. $selected = Array("", "");
  366. $selected[$page->get_filter("GROUP")] = "selected";
  367. ?>
  368. <select name='group' id='filter_group'>
  369. <option value='0' <?=$selected[0]?>>Slot</option>
  370. <option value='1' <?=$selected[1]?>>Type</option>
  371. </select>
  372. </td>
  373. </tr>
  374. </table>
  375. <input type='submit' value='Apply'/>
  376. </form>
  377. </aside> <!-- #filters -->
  378. <main>
  379. <section class='content' id='runes'>
  380. <h2>
  381. Runes
  382. </h2>
  383. <table>
  384. <?php
  385. $prev_group = "";
  386. $group = "";
  387. $group_title = "";
  388. $group_image = "";
  389. foreach ($page->get_runes() as $rune){
  390. switch ($page->get_filter("GROUP")){
  391. case 1: // "TYPE":
  392. $group = $rune->get_set()->get_name();
  393. $group_title = $rune->get_set()->get_name();
  394. $group_image = URL::IMG["RUNE"] . str_pad($rune->get_set()->get_id(), 2, '0', STR_PAD_LEFT) . ".png";
  395. break;
  396. default:
  397. $group = $rune->get_slot();
  398. $group_title = "Slot " . $rune->get_slot();
  399. $group_image = URL::IMG["RUNE"] . "base.png";
  400. }
  401. if ($prev_group != $group){
  402. if ($prev_group == ""){
  403. ?>
  404. <tr>
  405. <td class='header'>
  406. <?php
  407. }
  408. else{
  409. ?>
  410. </td>
  411. </tr>
  412. <tr>
  413. <td class='header'>
  414. <?php
  415. }
  416. $prev_group = $group;
  417. ?>
  418. <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
  419. <span>
  420. <?=$group_title?>
  421. </span>
  422. </td>
  423. </tr>
  424. <tr>
  425. <td>
  426. <?php
  427. }
  428. ?>
  429. <?=HTML::rune_table($rune, $rune->get_unit())?>
  430. <?php
  431. }
  432. ?>
  433. </td> <!-- Close last group -->
  434. </tr>
  435. </table>
  436. </section>
  437. </main>
  438. <?php
  439. include __DIR__ . "/inc/footer.php";
  440. ?>
  441. </body>
  442. </html>