runes.php 20 KB

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