runes.php 19 KB

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