runs.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <?php
  2. global $AREA_TYPE;
  3. global $SCENARIO;
  4. global $UID;
  5. ?>
  6. <!DOCTYPE html>
  7. <html lang='en'>
  8. <head>
  9. <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
  10. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
  11. <title><?=$page->title?></title>
  12. <link rel='shortcut icon' href='<?=$page->favicon?>'/>
  13. <!-- CSS files -->
  14. <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
  15. <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>runs.css'/>
  16. <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
  17. <!-- Meta tags -->
  18. <link rel='canonical' href='<?=$page->canonical?>'/>
  19. <link rel='author' href='<?=$page->author?>'/>
  20. <link rel='publisher' href='<?=$page->author?>'/>
  21. <meta name='description' content='<?=$page->description?>'/>
  22. <meta property='og:title' content='<?=$page->title?>'/>
  23. <meta property='og:url' content='<?=$page->canonical?>'/>
  24. <meta property='og:description' content='<?=$page->description?>'/>
  25. <meta property='og:image' content='<?=$page->icon?>'/>
  26. <meta property='og:site_name' content='<?=$page->name?>'/>
  27. <meta property='og:type' content='website'/>
  28. <meta property='og:locale' content='en'/>
  29. <meta name='twitter:card' content='summary'/>
  30. <meta name='twitter:title' content='<?=$page->title?>'/>
  31. <meta name='twitter:description' content='<?=$page->description?>'/>
  32. <meta name='twitter:image' content='<?=$page->icon?>'/>
  33. <meta name='twitter:url' content='<?=$page->canonical?>'/>
  34. <meta name='robots' content='index follow'/>
  35. <script>
  36. function saveForm(id, show){
  37. if (show === true){
  38. document.getElementById('save_team').style.display = 'block';
  39. document.getElementById('save_id').value = id;
  40. }
  41. else{
  42. document.getElementById('save_team').style.display = 'none';
  43. }
  44. }
  45. function saveTeam(){
  46. var id = document.getElementById('save_id').value;
  47. var name = document.getElementById('save_team_name').value;
  48. var description = document.getElementById('save_team_description').value;
  49. if (name == ''){
  50. alert('Name required')
  51. return;
  52. }
  53. var xhttp = new XMLHttpRequest();
  54. xhttp.onreadystatechange = function() {
  55. if (this.readyState == 4 && this.status == 200) {
  56. saveForm(null, false);
  57. }
  58. };
  59. xhttp.open("POST", "/action/save_run_team/", true);
  60. xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  61. xhttp.send('uid=<?=$UID?>&run=' + id + '&name=' + encodeURI(name) + '&description=' + encodeURI(description));
  62. }
  63. /**
  64. * Shows or hiddes the filters panel.
  65. */
  66. function toggleFilters(){
  67. var content = document.getElementById('filters_content');
  68. var slid = document.getElementById('filters_slid');
  69. if (content.style.maxHeight != '30em'){
  70. content.style.maxHeight = '30em';
  71. slid.style.transform = 'rotate(90deg)';
  72. }
  73. else{
  74. content.style.maxHeight = '0px';
  75. slid.style.transform = 'rotate(0deg)';
  76. }
  77. };
  78. </script>
  79. </head>
  80. <body>
  81. <?php
  82. include __DIR__ . "/inc/header.php";
  83. ?>
  84. <section class='filters'>
  85. <h2 id='filters_title' onClick='toggleFilters();'>
  86. <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
  87. Run filters
  88. </h2>
  89. <article id='filters_content'>
  90. <?php
  91. $filters = $page->filters;
  92. $custom_filters = $page->custom_filters;
  93. include __DIR__ . "/inc/filter_runs.php";
  94. ?>
  95. </article>
  96. </section> <!-- #filters -->
  97. <section class='content'>
  98. <h2>
  99. Runs
  100. </h2>
  101. <article>
  102. <table id='runs'>
  103. <tr>
  104. <th>
  105. Area
  106. </th>
  107. <th>
  108. Date
  109. </th>
  110. <th>
  111. Team
  112. </th>
  113. <th>
  114. Time
  115. </th>
  116. <th>
  117. Reward
  118. </th>
  119. </tr>
  120. <?php
  121. foreach ($page->runs as $run){
  122. $enable_save = true;
  123. ?>
  124. <tr>
  125. <td class='area'>
  126. <div class='area'>
  127. <img title='<?=$run->area->name?>' class='area' src='<?=$run->area->get_image($run->stage)?>'/>
  128. <?php
  129. if ($run->stage > 0){
  130. ?>
  131. <span class='stage'><?=$run->stage?></span>
  132. <?php
  133. }
  134. // TODO: Labyrinth difficulty
  135. if (in_array($run->area->id, $SCENARIO)){
  136. ?>
  137. <span class='difficulty'>
  138. <?php
  139. for ($i = 0; $i < $run->difficulty; $i ++){
  140. ?>
  141. <img class='difficulty' src='<?=$path["img"]["icon"]?>star.png'/>
  142. <?php
  143. }
  144. ?>
  145. </span>
  146. <?php
  147. }
  148. ?>
  149. </div>
  150. </td>
  151. <td class='date'>
  152. <?php
  153. $date = date_create($run->dtime);
  154. ?>
  155. <?=date_format($date, "Y/m/d H:i:s")?>
  156. </td>
  157. <td class='team'>
  158. <?php
  159. if ($run->helper == 1){
  160. $enable_save = false;
  161. ?>
  162. <div class='monster_panel helper'>
  163. <img class='monster' title='Friend/Menstor' src='<?=$path["img"]["currency"]?>socialpoint.png'/>
  164. </div>
  165. <?php
  166. }
  167. foreach ($run->party as $party){
  168. if ($party instanceof K_Unit){
  169. $enable_save = false;
  170. $disabled = "disabled";
  171. }
  172. else{
  173. $disabled = "";
  174. }
  175. if ($disabled == ""){
  176. ?>
  177. <a target='_blank' href='/<?=$UID?>>/monster/<?=$party->id?>'>
  178. <?php
  179. }
  180. ?>
  181. <div class='monster_panel <?=$disabled?>'>
  182. <?=html_unit_panel($party)?>
  183. </div>
  184. <?php
  185. if ($disabled == ""){
  186. ?>
  187. </a>
  188. <?php
  189. }
  190. }
  191. ?>
  192. </td>
  193. <td class='time'>
  194. <?php
  195. if ($run->win == 1){
  196. $s = floor($run->time / 1000);
  197. $m = floor($s / 60);
  198. $s = floor($s % 60);
  199. $ms = ($run-> time - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
  200. $s = str_pad($s, 2, '0', STR_PAD_LEFT);
  201. $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
  202. ?>
  203. <?=$m?>:<?=$s?><span class='ms'>.<?=$ms?></span>
  204. <?php
  205. }
  206. else{
  207. ?>
  208. <span class='defeated'>Defeated</span>
  209. <?php
  210. }
  211. ?>
  212. </td>
  213. <td class='reward'>
  214. <?php
  215. if ($run->energy > 0){
  216. ?>
  217. <div class='item'>
  218. <img class='item' title='Energy' src='<?=$path["img"]["currency"]?>energy.png'/>
  219. <span class='item'><?=$run->energy?></span>
  220. </div>
  221. <?php
  222. }
  223. if ($run->mana > 0){
  224. ?>
  225. <div class='item'>
  226. <img class='item' title='Mana' src='<?=$path["img"]["currency"]?>mana.png'/>
  227. <span class='item'><?=$run->mana?></span>
  228. </div>
  229. <?php
  230. }
  231. if ($run->crystal > 0){
  232. ?>
  233. <div class='item'>
  234. <img class='item' title='Crystal' src='<?=$path["img"]["currency"]?>crystal.png'/>
  235. <span class='item'><?=$run->crystal?></span>
  236. </div>
  237. <?php
  238. }
  239. foreach ($run->unit as $unit){
  240. ?>
  241. <div class='item'>
  242. <img class='item' title='<?=$unit->title?>' src='<?=$unit->get_image()?>'/>
  243. </div>
  244. <?php
  245. }
  246. foreach ($run->item as $item){
  247. ?>
  248. <div class='item'>
  249. <img class='item' title='<?=$item->name?>' src='<?=$item->get_image()?>'/>
  250. <span class='item'><?=$item->amount?></span>
  251. </div>
  252. <?php
  253. }
  254. foreach ($run->sd as $sd){
  255. ?>
  256. <div class='item'>
  257. <img class='item' title='<?=$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
  258. <img class='item' title=' ' src='<?=$path["img"]["misc"]?>mask-sd.png'/>
  259. </div>
  260. <?php
  261. }
  262. foreach ($run->unit_piece as $piece){
  263. ?>
  264. <div class='item'>
  265. <img class='item' title='<?=$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
  266. <img class='item' title=' ' src='<?=$path["img"]["misc"]?>mask-piece.png'/>
  267. <span class='item'><?=$piece->quantity?></span>
  268. </div>
  269. <?php
  270. }
  271. if ($run->shapeshifting > 0){
  272. ?>
  273. <div class='item'>
  274. <img class='item' title='Shapeshifting Stones' src='<?=$path["img"]["currency"]?>costumestone.png'/>
  275. <span class='item'><?=$run->shapeshifting?></span>
  276. </div>
  277. <?php
  278. }
  279. foreach ($run->rune as $rune){
  280. ?>
  281. <div class='item item_rune'>
  282. <img class='item' title='Rune' src='<?=$path["img"]["rune"]?>base.png'/>
  283. <?=html_rune_table($rune)?>
  284. </div>
  285. <?php
  286. }
  287. ?>
  288. </td>
  289. <td class='action'>
  290. <?php
  291. if ($enable_save){
  292. ?>
  293. <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=$path["img"]["icon"]?>save.png'/>
  294. <?php
  295. }
  296. ?>
  297. </td>
  298. </tr>
  299. <?php
  300. }
  301. ?>
  302. </table>
  303. </article>
  304. </section>
  305. <section id='save_team' class='content'>
  306. <h2>
  307. Save run
  308. </h2>
  309. <article>
  310. <input id='save_id' type='hidden' value=''/>
  311. <table>
  312. <tr>
  313. <td class='save_title'>
  314. Name
  315. </td>
  316. <td class='save_values'>
  317. <input type='text' id='save_team_name' name='name'/>
  318. </td>
  319. </tr>
  320. <tr>
  321. <td class='save_title'>
  322. Description
  323. </td>
  324. <td class='save_values'>
  325. <textarea id='save_team_description' name='description'></textarea>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td colspan='2'>
  330. <input type='button' value='Save' onClick='saveTeam();'/>
  331. <input type='button' value='Close' onClick='saveForm(null, false);'/>
  332. </td>
  333. </tr>
  334. </table>
  335. </article>
  336. </section>
  337. <?php
  338. include __DIR__ . "/inc/footer.php";
  339. ?>
  340. </body>
  341. </html>