artifacts.php 14 KB

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