artifacts.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?php
  2. /**
  3. * Artifacts view.
  4. *
  5. * Contains the view layout and 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 Artifacts_Page $page The page model.
  12. * @var Artifacts_Page $page The page model.
  13. */
  14. ?>
  15. <!DOCTYPE html>
  16. <html lang='en'>
  17. <head>
  18. <?=$page->generate_head()?>
  19. </head>
  20. <body>
  21. <?php
  22. include __DIR__ . "/inc/header_app.php";
  23. include __DIR__ . "/inc/header_player.php";
  24. ?>
  25. <aside class='filters'>
  26. <h2>
  27. Artifacts
  28. </h2>
  29. <p>
  30. Manage your enchantments
  31. </p>
  32. <form action='/player/<?=get_context()->get_player()->get_id()?>/artifacts/' method='get' id='filter_artifacts' class='filter'>
  33. <table>
  34. <tr>
  35. <td class='label'>
  36. Element:
  37. </td>
  38. <td>
  39. <select multiple name='element[]' id='filter_element'>
  40. <?php
  41. $reflect = new ReflectionClass("ELEMENT_ID");
  42. foreach($reflect->getConstants() as $name => $id){
  43. if ($id != ELEMENT_ID::PURE){
  44. $selected = "";
  45. if (in_array($id, $page->get_filter("ELEMENT"))){
  46. $selected = "selected='selected'";
  47. }
  48. ?>
  49. <option value='<?=$id?>' <?=$selected?>><?=$name?></option>
  50. <?php
  51. }
  52. }
  53. ?>
  54. </select>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td class='label'>
  59. Type:
  60. </td>
  61. <td>
  62. <select multiple name='archetype[]' id='filter_archetype'>
  63. <?php
  64. $reflect = new ReflectionClass("ARCHETYPE_ID");
  65. foreach($reflect->getConstants() as $name => $id){
  66. if ($id != ARCHETYPE_ID::NONE && $id != ARCHETYPE_ID::MATERIAL){
  67. $selected = "";
  68. if (in_array($id, $page->get_filter("ARCHETYPE"))){
  69. $selected = "selected='selected'";
  70. }
  71. ?>
  72. <option value='<?=$id?>' <?=$selected?>><?=$name?></option>
  73. <?php
  74. }
  75. }
  76. ?>
  77. </select>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td class='label'>
  82. Main stat:
  83. </td>
  84. <td>
  85. <select multiple name='main_stat[]' id='filter_main_stat'>
  86. <?php
  87. $reflect = new ReflectionClass("ARTIFACT_STAT_ID");
  88. foreach($reflect->getConstants() as $name => $id){
  89. $selected = "";
  90. if (in_array($id, $page->get_filter("MAIN"))){
  91. $selected = "selected='selected'";
  92. }
  93. ?>
  94. <option value='<?=$id?>' <?=$selected?>><?=$name?></option>
  95. <?php
  96. }
  97. ?>
  98. </select>
  99. </td>
  100. </tr>
  101. <tr>
  102. <td class='label'>
  103. Level:
  104. </td>
  105. <td>
  106. <input type='number' name='min_level' id='filter_level_min' min='0' max='15' value='<?=$page->get_filter("MIN_LEVEL")?>'/>
  107. -
  108. <input type='number' name='max_level' id='filter_level_max' min='0' max='15' value='<?=$page->get_filter("MAX_LEVEL")?>'/>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td class='label'>
  113. Quality:
  114. </td>
  115. <td>
  116. <?php
  117. $selected = Array("", "", "", "", "");
  118. $selected[$page->get_filter("MIN_QUALITY") - 1] = "selected";
  119. ?>
  120. <select name='min_quality' id='filter_quality_min'>
  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. -
  128. <?php
  129. $selected = Array("", "", "", "", "");
  130. $selected[$page->get_filter("MAX_QUALITY") - 1] = "selected";
  131. ?>
  132. <select name='max_quality' id='filter_quality_max'>
  133. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  134. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  135. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  136. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  137. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  138. </select>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td class='label'>
  143. O. quality:
  144. </td>
  145. <td>
  146. <?php
  147. $selected = Array("", "", "", "", "");
  148. $selected[$page->get_filter("MIN_ORIGINAL_QUALITY") - 1] = "selected";
  149. ?>
  150. <select name='min_original_quality' id='filter_original_quality_min'>
  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. -
  158. <?php
  159. $selected = Array("", "", "", "", "");
  160. $selected[$page->get_filter("MAX_ORIGINAL_QUALITY") - 1] = "selected";
  161. ?>
  162. <select name='max_original_quality' id='filter_original_quality_max'>
  163. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  164. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  165. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  166. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  167. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  168. </select>
  169. </td>
  170. </tr>
  171. <tr>
  172. <td class='label'>
  173. Assigned:
  174. </td>
  175. <td>
  176. <?php
  177. $selected = Array("", "", "", "", "");
  178. $selected[$page->get_filter("ASSIGNED")] = "selected";
  179. ?>
  180. <select name='assigned' id='filter_assigned'>
  181. <option value='0' <?=$selected[0]?>>All</option>
  182. <option value='1' <?=$selected[1]?>>Assigned</option>
  183. <option value='2' <?=$selected[2]?>>Unassigned</option>
  184. <option value='3' <?=$selected[3]?>>All (no storage)</option>
  185. <option value='4' <?=$selected[4]?>>Assigned (no storage)</option>
  186. </select>
  187. </td>
  188. </tr>
  189. </table>
  190. <div id='filter_apply'>
  191. <input type='submit' value='Apply'/>
  192. </div>
  193. </form>
  194. </aside> <!-- #filters -->
  195. <main>
  196. <section class='content' id='artifacts'>
  197. <h2>
  198. Artifacts
  199. </h2>
  200. <table>
  201. <?php
  202. $prev_group = "";
  203. $group = "";
  204. $group_title = "";
  205. $group_image = "";
  206. foreach ($page->get_artifacts() as $artifact){
  207. $group = $artifact->get_type() . "-" . $artifact->get_element() . "-" . $artifact->get_archetype();
  208. if ($prev_group != $group){
  209. switch ($artifact->get_type()){
  210. case ARTIFACT_TYPE::ELEMENT:
  211. switch ($artifact->get_element()){
  212. case ELEMENT_ID::WATER:
  213. $group_title = "Water";
  214. $group_image = URL::IMG["ARTIFACT"] . "element_water.png";
  215. break;
  216. case ELEMENT_ID::FIRE:
  217. $group_title = "Fire";
  218. $group_image = URL::IMG["ARTIFACT"] . "element_fire.png";
  219. break;
  220. case ELEMENT_ID::WIND:
  221. $group_title = "Wind";
  222. $group_image = URL::IMG["ARTIFACT"] . "element_wind.png";
  223. break;
  224. case ELEMENT_ID::LIGHT:
  225. $group_title = "Light";
  226. $group_image = URL::IMG["ARTIFACT"] . "element_light.png";
  227. break;
  228. case ELEMENT_ID::DARK:
  229. $group_title = "Dark";
  230. $group_image = URL::IMG["ARTIFACT"] . "element_dark.png";
  231. break;
  232. }
  233. break;
  234. case ARTIFACT_TYPE::ARCHETYPE:
  235. switch ($artifact->get_archetype()){
  236. case ARCHETYPE_ID::ATTACK:
  237. $group_title = "Attack";
  238. $group_image = URL::IMG["ARTIFACT"] . "type_attack.png";
  239. break;
  240. case ARCHETYPE_ID::DEFENSE:
  241. $group_title = "Defense";
  242. $group_image = URL::IMG["ARTIFACT"] . "type_defense.png";
  243. break;
  244. case ARCHETYPE_ID::SUPPORT:
  245. $group_title = "Support";
  246. $group_image = URL::IMG["ARTIFACT"] . "type_support.png";
  247. break;
  248. case ARCHETYPE_ID::HP:
  249. $group_title = "HP";
  250. $group_image = URL::IMG["ARTIFACT"] . "type_hp.png";
  251. break;
  252. }
  253. }
  254. if ($prev_group == ""){
  255. ?>
  256. <tr>
  257. <td class='header'>
  258. <?php
  259. }
  260. else{
  261. ?>
  262. </td>
  263. </tr>
  264. <tr>
  265. <td class='header'>
  266. <?php
  267. }
  268. $prev_group = $group;
  269. ?>
  270. <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
  271. <span>
  272. <?=$group_title?>
  273. </span>
  274. </td>
  275. </tr>
  276. <tr>
  277. <td>
  278. <?php
  279. }
  280. ?>
  281. <?=HTML::artifact_table($artifact, $artifact->get_unit())?>
  282. <?php
  283. }
  284. ?>
  285. </td> <!-- Close last group -->
  286. </tr>
  287. </table>
  288. </section>
  289. </main>
  290. <?php
  291. include __DIR__ . "/inc/footer.php";
  292. ?>
  293. </body>
  294. </html>