report_rune_enchantment.php 24 KB

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