enchantments.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. /**
  3. * Artifacts view.
  4. *
  5. * Contains the view layout and ome code to present the data.
  6. *
  7. * @category View
  8. * @var Artifacts_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?>enchantments.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. </script>
  84. </head>
  85. <body>
  86. <?php
  87. include __DIR__ . "/inc/header.php";
  88. ?>
  89. <aside class='filters'>
  90. <h2>
  91. Enchantments
  92. </h2>
  93. <p>
  94. Manage your enchantments
  95. </p>
  96. <form action='/<?=get_context()->get_player()->get_id()?>/enchantments/' method='get' id='filter_artifacts' class='filter'>
  97. <table>
  98. <tr>
  99. <td class='label'>
  100. Type:
  101. </td>
  102. <td>
  103. <select multiple name='type[]' id='filter_type'>
  104. <?php
  105. $selected = "";
  106. if (in_array("GRI", $page->filters["TYPE"])){
  107. $selected = "selected='selected'";
  108. }
  109. ?>
  110. <option value='GRI' <?=$selected?>>Grindstone</option>
  111. <?php
  112. $selected = "";
  113. if (in_array("GEM", $page->filters["TYPE"])){
  114. $selected = "selected='selected'";
  115. }
  116. ?>
  117. <option value='GEM' <?=$selected?>>Gem</option>
  118. </select>
  119. </td>
  120. </tr>
  121. <tr>
  122. <td class='label'>
  123. Quality:
  124. </td>
  125. <td>
  126. <?php
  127. $selected = Array("", "", "", "", "");
  128. $selected[$page->filters["MIN_QUALITY"] - 1] = "selected";
  129. ?>
  130. <select name='min_quality' id='filter_quality_min'>
  131. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  132. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  133. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  134. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  135. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  136. </select>
  137. -
  138. <?php
  139. $selected = Array("", "", "", "", "");
  140. $selected[$page->filters["MAX_QUALITY"] - 1] = "selected";
  141. ?>
  142. <select name='max_quality' id='filter_quality_max'>
  143. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  144. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  145. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  146. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  147. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  148. </select>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td class='label'>
  153. Rune:
  154. </td>
  155. <td class='rune'>
  156. <div>
  157. <select multiple name='rune[]' id='filter_rune'>
  158. <?php
  159. $selected = "";
  160. if (in_array(0, $page->filters["RUNE"])){
  161. $selected = "selected='selected'";
  162. }
  163. ?>
  164. <option value='0' <?=$selected?>>Inmemorial</option>
  165. <?php
  166. $reflect = new ReflectionClass("RUNE_SET_ID");
  167. $i = 1;
  168. $j = 1;
  169. foreach($reflect->getConstants() as $name => $id){
  170. $selected = "";
  171. if (in_array($id, $page->filters["TYPE"])){
  172. $selected = "selected='selected'";
  173. }
  174. $name_format = ucwords(strtolower($name));
  175. if (strlen($name_format) > 9){
  176. $name_format = substr($name_format, 0, 9) . ".";
  177. }
  178. ?>
  179. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  180. <?php
  181. if (($i + 1) % 6 == 0 && ($i + 1) < sizeof($reflect->getConstants())){
  182. ?>
  183. </select><select multiple name='type[]' class='select_type' id='select_type_<?=$j?>' onMouseDown='fixTypeSelect(<?=$j?>, event);'>
  184. <?php
  185. $j ++;
  186. }
  187. $i ++;
  188. }
  189. ?>
  190. </select>
  191. </div>
  192. </td>
  193. </tr>
  194. <tr>
  195. <td class='label'>
  196. Stat:
  197. </td>
  198. <td class='stats'>
  199. <div>
  200. <select multiple name='stat[]' id='filter_stat'>
  201. <?php
  202. $reflect = new ReflectionClass("RUNE_STAT_ID");
  203. $i = 0;
  204. $j = 1;
  205. foreach($reflect->getConstants() as $name => $id){
  206. $selected = "";
  207. if (in_array($id, $page->filters["SUB"])){
  208. $selected = "selected='selected'";
  209. }
  210. $name_format = ucwords(str_replace("_P", "%", $name));
  211. ?>
  212. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  213. <?php
  214. if (($i + 1) % 2 == 0){
  215. ?>
  216. </select><select multiple name='main_stat[]' class='select_sub' id='filter_sub_stat_<?=$j?>' onMouseDown='fixSubSelect(<?=$j?>, event);'>
  217. <?php
  218. $j ++;
  219. }
  220. $i ++;
  221. }
  222. ?>
  223. </select>
  224. </div>
  225. </td>
  226. </tr>
  227. </table>
  228. <div id='filter_apply'>
  229. <input type='submit' value='Apply'/>
  230. </div>
  231. </form>
  232. </aside> <!-- #filters -->
  233. <main>
  234. <section class='content' id='enchantments'>
  235. <h2>
  236. Enchantments
  237. </h2>
  238. <table>
  239. <?php
  240. $prev_group = "";
  241. $group = "";
  242. $group_title = "";
  243. $group_image = "";
  244. foreach ($page->grindstones as $grindstone){
  245. $group = $grindstone->get_rune_set()->id . "-" . $grindstone->is_inmemorial();
  246. if ($prev_group != $group){
  247. if ($grindstone->is_inmemorial()){
  248. $group_title = "Inmemorial";
  249. $group_image = URL::IMG["ICON"] . "star.png";
  250. }
  251. else{
  252. $group_title = $grindstone->rune->name;
  253. $group_image = URL::IMG["RUNE"] . str_pad($grindstone->get_rune_set()->id, 2, '0', STR_PAD_LEFT) . ".png";
  254. }
  255. if ($prev_group == ""){
  256. ?>
  257. <tr>
  258. <td class='header'>
  259. <?php
  260. }
  261. else{
  262. ?>
  263. </td>
  264. </tr>
  265. <tr>
  266. <td class='header'>
  267. <?php
  268. }
  269. $prev_group = $group;
  270. ?>
  271. <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
  272. <span>
  273. <?=$group_title?>
  274. </span>
  275. </td>
  276. </tr>
  277. <tr>
  278. <td>
  279. <?php
  280. }
  281. ?>
  282. <?=HTML::enchantment_panel($grindstone)?>
  283. <?php
  284. }
  285. ?>
  286. </td> <!-- Close last group -->
  287. </tr>
  288. </table>
  289. </section>
  290. </main>
  291. <?php
  292. include __DIR__ . "/inc/footer.php";
  293. ?>
  294. </body>
  295. </html>