report_rune_enchantment.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <?php
  2. /**
  3. * Rune Enchantment report 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 Report_Rune_Enchantment_Page $page The page model.
  12. * @var Report_Rune_Enchantment_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 grindstone stat selects as one.
  22. *
  23. * @param clicked Numeric order of the select clicked.
  24. * @param event onMouseDown event.
  25. */
  26. function fixGrindStatSelect(clicked, event){
  27. if (!event.ctrlKey){
  28. console.log("NO CTRL: " + clicked);
  29. // If controll was not being held, clean all other selects
  30. if (clicked == 0){
  31. document.getElementById("filter_grind_stat_1").selectedIndex = -1;
  32. }
  33. else if (clicked == 1){
  34. document.getElementById("filter_grind_stat_0").selectedIndex = -1;
  35. }
  36. }
  37. }
  38. /**
  39. * Hack to treat all enchant stat from selects as one.
  40. *
  41. * @param clicked Numeric order of the select clicked.
  42. * @param event onMouseDown event.
  43. */
  44. function fixEnchantStatFromSelect(clicked, event){
  45. if (!event.ctrlKey){
  46. // If controll was not being held, clean all other selects
  47. if (clicked == 0){
  48. document.getElementById("filter_gem_stat_from_1").selectedIndex = -1;
  49. }
  50. else if (clicked == 1){
  51. document.getElementById("filter_gem_stat_from_0").selectedIndex = -1;
  52. }
  53. }
  54. }
  55. /**
  56. * Hack to treat all enchant stat to selects as one.
  57. *
  58. * @param clicked Numeric order of the select clicked.
  59. * @param event onMouseDown event.
  60. */
  61. function fixEnchantStatToSelect(clicked, event){
  62. if (!event.ctrlKey){
  63. // If controll was not being held, clean all other selects
  64. if (clicked == 0){
  65. document.getElementById("filter_gem_stat_to_1").selectedIndex = -1;
  66. }
  67. else if (clicked == 1){
  68. document.getElementById("filter_gem_stat_to_0").selectedIndex = -1;
  69. }
  70. }
  71. }
  72. </script>
  73. </head>
  74. <body>
  75. <header>
  76. <?php
  77. include __DIR__ . "/inc/header_app.php";
  78. include __DIR__ . "/inc/header_player.php";
  79. ?>
  80. </header>
  81. <aside>
  82. <h2>
  83. Report filters
  84. </h2>
  85. <form action='/<?=get_context()->get_player()->get_id()?>/report/rune_enchantment/' method='get' id='filter_runeenchantment' class='filter'>
  86. <table>
  87. <tr>
  88. <td colspan='2' class='header'>
  89. Monster
  90. </td>
  91. </tr>
  92. <tr>
  93. <td class='label'>
  94. Name:
  95. <div class='help_tooltip'>
  96. <p>
  97. Units whose name contains this (case insensitive).
  98. </p>
  99. </div>
  100. </td>
  101. <td>
  102. <input type='text' name='monster_name' id='filter_name' value='<?=$page->get_filter("MONSTER_NAME")?>'/>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td class='label'>
  107. Stars:
  108. </td>
  109. <td>
  110. <input type='number' name='monster_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$page->get_filter("MONSTER_MIN_STARS")?>'/>
  111. -
  112. <input type='number' name='monster_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$page->get_filter("MONSTER_MAX_STARS")?>'/>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td class='label'>
  117. Show units:
  118. </td>
  119. <td>
  120. <?php
  121. $selected = Array("", "", "", "", "");
  122. $selected[$page->get_filter("TEAM")] = "selected";
  123. ?>
  124. <select name='unit'>
  125. <option value='0' <?=$selected[0]?>>All</option>
  126. <option value='1' <?=$selected[1]?>>In teams</option>
  127. <option value='2' <?=$selected[2]?>>In teams (score > 0)</option>
  128. </select>
  129. </td>
  130. </tr>
  131. <tr>
  132. <td class='label' colspan='2'>
  133. <?php
  134. $checked = "";
  135. if ($page->get_filter("MONSTER_IN_STORAGE")){
  136. $checked = "checked";
  137. }
  138. ?>
  139. <input type='checkbox' name='monster_in_storage' id='filter_monster_in_storage' <?=$checked?>/>
  140. <label for='filter_monster_in_storage'>Show monsters in storage</label>
  141. </td>
  142. </tr>
  143. <tr>
  144. <td colspan='2' class='header'>
  145. Runes
  146. </td>
  147. </tr>
  148. <tr>
  149. <td class='label'>
  150. Stars:
  151. </td>
  152. <td>
  153. <input type='number' name='rune_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$page->get_filter("RUNE_MIN_STARS")?>'/>
  154. -
  155. <input type='number' name='rune_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$page->get_filter("RUNE_MAX_STARS")?>'/>
  156. </td>
  157. </tr>
  158. <tr>
  159. <td class='label'>
  160. Level:
  161. </td>
  162. <td>
  163. <input type='number' name='rune_min_level' id='filter_level_min' min='0' max='15' value='<?=$page->get_filter("RUNE_MIN_LEVEL")?>'/>
  164. -
  165. <input type='number' name='rune_max_level' id='filter_level_max' min='0' max='15' value='<?=$page->get_filter("RUNE_MAX_LEVEL")?>'/>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td class='label'>
  170. Quality:
  171. </td>
  172. <td>
  173. <?php
  174. $selected = Array("", "", "", "", "");
  175. $selected[$page->get_filter("RUNE_MIN_QUALITY") - 1] = "selected";
  176. ?>
  177. <select name='rune_min_quality' id='filter_quality_min'>
  178. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  179. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  180. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  181. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  182. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  183. </select>
  184. -
  185. <?php
  186. $selected = Array("", "", "", "", "");
  187. $selected[$page->get_filter("RUNE_MAX_QUALITY") - 1] = "selected";
  188. ?>
  189. <select name='rune_max_quality' id='filter_quality_max'>
  190. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  191. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  192. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  193. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  194. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  195. </select>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td class='label'>
  200. O. quality:
  201. </td>
  202. <td>
  203. <?php
  204. $selected = Array("", "", "", "", "");
  205. $selected[$page->get_filter("RUNE_MIN_ORIGINAL_QUALITY") - 1] = "selected";
  206. ?>
  207. <select name='rune_min_original_quality' id='filter_original_quality_min'>
  208. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  209. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  210. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  211. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  212. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  213. </select>
  214. -
  215. <?php
  216. $selected = Array("", "", "", "", "");
  217. $selected[$page->get_filter("RUNE_MAX_ORIGINAL_QUALITY") - 1] = "selected";
  218. ?>
  219. <select name='rune_max_original_quality' id='filter_original_quality_max'>
  220. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  221. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  222. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  223. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  224. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  225. </select>
  226. </td>
  227. </tr>
  228. <tr>
  229. <td class='label'>
  230. Efficiency:
  231. </td>
  232. <td>
  233. <input type='number' name='rune_min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$page->get_filter("RUNE_MIN_EFFICIENCY")?>'/>%
  234. -
  235. <input type='number' name='rune_max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$page->get_filter("RUNE_MAX_EFFICIENCY")?>'/>%
  236. </td>
  237. </tr>
  238. <tr>
  239. <td class='label'>
  240. Max. eff.:
  241. </td>
  242. <td>
  243. <input type='number' name='rune_min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$page->get_filter("RUNE_MIN_MAX_EFFICIENCY")?>'/>%
  244. -
  245. <input type='number' name='rune_max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$page->get_filter("RUNE_MAX_MAX_EFFICIENCY")?>'/>%
  246. </td>
  247. </tr>
  248. <tr>
  249. <td class='slot label'>
  250. Slot:
  251. </td>
  252. <td class='slot'>
  253. <select multiple name='rune_slot[]' id='filter_slot'>
  254. <?php
  255. for ($i = 1; $i <= 6; $i ++){
  256. if (in_array($i, $page->get_filter("RUNE_SLOT"))){
  257. $selected = "selected='selected'";
  258. }
  259. else{
  260. $selected = "";
  261. }
  262. ?>
  263. <option value='<?=$i?>' <?=$selected?>><?=$i?></option>
  264. <?php
  265. }
  266. ?>
  267. </select>
  268. </td>
  269. </tr>
  270. <tr>
  271. <td colspan='2' class='header'>
  272. <?php
  273. $checked = "";
  274. if ($page->get_filter("GRIND")){
  275. $checked = "checked";
  276. }
  277. ?>
  278. <input type='checkbox' name='grind' id='filter_grind' <?=$checked?>/>
  279. <label for='filter_grind'>Grindstones</label>
  280. </td>
  281. </tr>
  282. <tr>
  283. <td class='label'>
  284. Min. quality:
  285. </td>
  286. <td>
  287. <?php
  288. $selected = Array("", "", "", "", "");
  289. $selected[$page->get_filter("GRIND_MIN_QUALITY") - 1] = "selected";
  290. ?>
  291. <select name='grind_min_quality'>
  292. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  293. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  294. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  295. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  296. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  297. </select>
  298. </td>
  299. </tr>
  300. <tr>
  301. <td class='stats label'>
  302. Stats:
  303. </td>
  304. <td class='stats'>
  305. <div>
  306. <select multiple name='grind_stat[]' id='filter_grind_stat_0' onMouseDown='fixGrindStatSelect(0, event);'>
  307. <?php
  308. $reflect = new ReflectionClass("RUNE_STAT_ID");
  309. $count = 1;
  310. $i = 0;
  311. foreach($reflect->getConstants() as $name => $id){
  312. $selected = "";
  313. if (in_array($id, $page->get_filter("GRIND_STAT"))){
  314. $selected = "selected='selected'";
  315. }
  316. $name_format = ucwords(str_replace("_P", "%", $name));
  317. ?>
  318. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  319. <?php
  320. if (($i + 1) % 2 == 0){
  321. ?>
  322. </select><select multiple name='grind_stat[]' id='filter_grind_stat_<?=$count?>' onMouseDown='fixGrindStatSelect(<?=$count?>, event);'>
  323. <?php
  324. $count ++;
  325. }
  326. $i ++;
  327. }
  328. ?>
  329. </select>
  330. </div>
  331. </td>
  332. </tr>
  333. <tr>
  334. <td colspan='2' class='header'>
  335. <?php
  336. $checked = "";
  337. if ($page->get_filter("GEM")){
  338. $checked = "checked";
  339. }
  340. ?>
  341. <input type='checkbox' name='gem' id='filter_gem' <?=$checked?>/>
  342. <label for='filter_gem'>Gems</label>
  343. </td>
  344. </tr>
  345. <tr>
  346. <td class='label'>
  347. Min. quality:
  348. </td>
  349. <td>
  350. <?php
  351. $selected = Array("", "", "", "", "");
  352. $selected[$page->get_filter("GEM_MIN_QUALITY") - 1] = "selected";
  353. ?>
  354. <select name='gem_min_quality'>
  355. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  356. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  357. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  358. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  359. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  360. </select>
  361. </td>
  362. </tr>
  363. <tr>
  364. <td class='stats label'>
  365. Replace...
  366. </td>
  367. <td class='stats'>
  368. <div>
  369. <select multiple name='gem_stat_from[]' id='filter_gem_stat_from_0' onMouseDown='fixEnchantStatFromSelect(0, event);'>
  370. <?php
  371. $reflect = new ReflectionClass("RUNE_STAT_ID");
  372. $count = 1;
  373. $i = 0;
  374. foreach($reflect->getConstants() as $name => $id){
  375. $selected = "";
  376. if (in_array($id, $page->get_filter("GEM_STAT_FROM"))){
  377. $selected = "selected='selected'";
  378. }
  379. $name_format = ucwords(str_replace("_P", "%", $name));
  380. ?>
  381. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  382. <?php
  383. if (($i + 1) % 2 == 0){
  384. ?>
  385. </select><select multiple name='gem_stat_from[]' id='filter_gem_stat_from_<?=$count?>' onMouseDown='fixEnchantStatFromSelect(<?=$count?>, event);'>
  386. <?php
  387. $count ++;
  388. }
  389. $i ++;
  390. }
  391. ?>
  392. </select>
  393. </div>
  394. </td>
  395. </tr>
  396. <tr>
  397. <td class='stats label'>
  398. ...with:
  399. </td>
  400. <td class='stats'>
  401. <div>
  402. <select multiple name='gem_stat_from[]' id='filter_gem_stat_to_0' onMouseDown='fixEnchantStatToSelect(0, event);'>
  403. <?php
  404. $reflect = new ReflectionClass("RUNE_STAT_ID");
  405. $count = 1;
  406. $i = 0;
  407. foreach($reflect->getConstants() as $name => $id){
  408. $selected = "";
  409. if (in_array($id, $page->get_filter("GEM_STAT_TO"))){
  410. $selected = "selected='selected'";
  411. }
  412. $name_format = ucwords(str_replace("_P", "%", $name));
  413. ?>
  414. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  415. <?php
  416. if (($i + 1) % 2 == 0){
  417. ?>
  418. </select><select multiple name='gem_stat_to[]' id='filter_gem_stat_to_<?=$count?>' onMouseDown='fixEnchantStatToSelect(<?=$count?>, event);'>
  419. <?php
  420. $count ++;
  421. }
  422. $i ++;
  423. }
  424. ?>
  425. </select>
  426. </div>
  427. </td>
  428. </tr>
  429. </table>
  430. <input type='submit' value='Apply'/>
  431. </form>
  432. </aside>
  433. <main>
  434. <section id='results' class='content'>
  435. <h2>
  436. <span>
  437. Available enchantments
  438. </span>
  439. </h2>
  440. <table id='results'>
  441. <?php
  442. foreach ($page->get_upgrades() as $upgrade){
  443. ?>
  444. <tr>
  445. <td class='header' colspan='2'>
  446. <a href='/<?=get_context()->get_player()->get_id()?>/units/<?=$upgrade["unit"]->get_id()?>/' target='_blank'>
  447. <div class='monster_panel'>
  448. <?=HTML::unit_panel($upgrade["unit"])?>
  449. </div>
  450. </a>
  451. <h4>
  452. <?=$upgrade["unit"]->get_title()?>
  453. </h4>
  454. </td>
  455. </tr>
  456. <?php
  457. foreach ($upgrade["upgrade"] as $rupgrade){
  458. ?>
  459. <tr>
  460. <td class='rune'>
  461. <?=HTML::rune_table($rupgrade["rune"])?>
  462. </td>
  463. <td class='upgrades'>
  464. <?php
  465. foreach ($rupgrade["enchantment"] as $enchantment){
  466. ?>
  467. <?=HTML::enchantment_panel($enchantment)?>
  468. <?php
  469. }
  470. ?>
  471. </td>
  472. </tr>
  473. <?php
  474. }
  475. }
  476. ?>
  477. </table>
  478. </section>
  479. </main>
  480. <?php
  481. include __DIR__ . "/inc/footer.php";
  482. ?>
  483. </body>
  484. </html>