HTML_Helper.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <?php
  2. /**
  3. * HTML helper file.
  4. *
  5. * Provides a helper to perform HTML operations.
  6. *
  7. * @category Helper.
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::HELPER . "Helper.php");
  13. require_once(PATH::ENTITY . "Unit.php");
  14. require_once(PATH::ENTITY . "K_Unit.php");
  15. require_once(PATH::ENTITY . "Building.php");
  16. require_once(PATH::ENTITY . "K_Building.php");
  17. require_once(PATH::ENTITY . "Decoration.php");
  18. require_once(PATH::ENTITY . "K_Decoration.php");
  19. require_once(PATH::ENTITY . "Rune.php");
  20. require_once(PATH::ENTITY . "Artifact.php");
  21. require_once(PATH::ENTITY . "Enchantment.php");
  22. require_once(PATH::ENTITY . "Inventory.php");
  23. /**
  24. * HTML helper.
  25. *
  26. * Contains utilities to parse and format HTML and to build elements.
  27. *
  28. * @category Helper.
  29. */
  30. final class HTML extends Helper{
  31. /**
  32. * Escapes HTML characters
  33. *
  34. * Alias for htmlspecialchars([input], ENT_QUOTES)
  35. *
  36. * @param string $input Text to escape.
  37. * @return string Escaped text.
  38. */
  39. public static function e($input){
  40. return htmlspecialchars($input, ENT_QUOTES);
  41. }
  42. /**
  43. * Generates a unit panel.
  44. *
  45. * @param Unit|K_Unit Entity to get the info from.
  46. * @return string HTML content for a monster panel. Empty on error.
  47. */
  48. public static function unit_panel($unit) {
  49. if ($unit instanceof Unit){
  50. $k = $unit->unit;
  51. $stars = $unit->stars;
  52. $level = true;
  53. $teams = (sizeof($unit->teams) > 0);
  54. $lock = $unit->lock;
  55. $storage = $unit->in_storage;
  56. $maxed = ($unit->level == 40 && $unit->are_skills_maxed());
  57. }
  58. elseif ($unit instanceof K_Unit){
  59. $k = $unit;
  60. $stars = $unit->base_stars;
  61. $level = false;
  62. $teams = 0;
  63. $lock = false;
  64. $storage = false;
  65. $maxed = false;
  66. }
  67. else{
  68. return "";
  69. }
  70. $html = "";
  71. if ($k->awakens_from == "" && $k->awakens_to == ""){
  72. // No to, no from
  73. if ($k->base_stars >= 4){
  74. // SFV Collab event units, always awakened.
  75. $star_class = "star_purple";
  76. }
  77. elseif($k->archetype == ARCHETYPE_ID::MATERIAL && $k->element == ELEMENT_ID::LIGHT){
  78. // Rainbowmon, always awakened
  79. $star_class = "star_purple";
  80. }
  81. elseif($k->archetype == ARCHETYPE_ID::MATERIAL && $k->element == ELEMENT_ID::DARK){
  82. // Devilmon, always unawakened
  83. $star_class = "star_silver";
  84. }
  85. else{
  86. // Unawakeable monster
  87. $star_class = "star_silver";
  88. }
  89. }
  90. elseif ($k->awakens_from != ""){
  91. // Already awakened
  92. if ($k->base_stars - $k->natural_stars == 1){
  93. // Normal awaken.
  94. $star_class ="star_purple";
  95. }
  96. else{
  97. // Second awaken.
  98. $star_class ="star_red";
  99. }
  100. }
  101. elseif ($k->awakens_to != ""){
  102. // Awakeable.
  103. $star_class ="star_gold";
  104. }
  105. $html .= "<span class='stars'>\n";
  106. for ($i = 0; $i < $stars; $i ++){
  107. $html .= "<img class='star $star_class' src='" . URL::IMG["ICON"] . "star.png'/>\n";
  108. }
  109. $html .= "</span>\n";
  110. $html .= "<img title='" . $unit->title . "' class='monster border_" . $k->element_name . "' src='" . $k->get_image() . "'/>\n";
  111. if ($level){
  112. $html .= "<span class='level'>\n";
  113. $html .= $unit->level . "\n";
  114. $html .= "</span>\n";
  115. }
  116. $html .= "<span class='badges'>\n";
  117. if ($maxed){
  118. $html .= "<img title='Maxed unit' src='" . URL::IMG["ICON"] . "maxed.png'>";
  119. }
  120. if ($teams > 0){
  121. $title = $teams . " teams";
  122. if ($teams == 1){
  123. $title = "1 team: " . $unit->teams[0]->name;
  124. }
  125. $html .= "<img title='$title' src='" . URL::IMG["ICON"] . "team.png'>";
  126. }
  127. if ($lock == 1){
  128. $html .= "<img title='Locked' src='" . URL::IMG["ICON"] . "lock.png'>";
  129. }
  130. if ($storage){
  131. $html .= "<img title='In storage' src='" . URL::IMG["ICON"] . "storage.png'>";
  132. }
  133. $html .= "</span>\n";
  134. return $html;
  135. }
  136. /**
  137. * Generates a transformed monster panel.
  138. *
  139. * @param Unit|K_Unit Entity to get the info from.
  140. * @return string HTML content for a monster panel. Empty on error.
  141. */
  142. public static function unit_transformation_panel($unit) {
  143. $html = "";
  144. if ($unit instanceof Unit){
  145. $k = $unit->unit;
  146. }
  147. elseif ($unit instanceof K_Unit){
  148. $k = $unit;
  149. }
  150. else{
  151. return "";
  152. }
  153. if ($k->transformation == null){
  154. return "";
  155. }
  156. $html .= "<div class='monster_transformation_panel'>\n";
  157. $html .= "<img title='" . $unit->title . " (transformed)' class='monster_transformation border_" . $k->element_name . "' src='" . $k->transformation->get_image() . "'/>\n";
  158. $html .= "</div>\n";
  159. return $html;
  160. }
  161. /**
  162. * Generates a rune panel.
  163. *
  164. * @param Rune rune Entity to get the info from.
  165. * @param Unit unit Optional. The unit the rune is assigned to.
  166. * @return string HTML content for a rune panel. Empty on error.
  167. */
  168. public static function rune_panel($rune, $unit = null) {
  169. if (!($rune instanceof Rune)){
  170. return "";
  171. }
  172. $html = "";
  173. $html .= "<div class='rune_panel rune_slot_" . $rune->slot . " rune_level_" . $rune->level . " rune_quality_" . strtolower($rune->quality_name) . " rune_original_quality_" . strtolower($rune->original_quality_name) . " rune_ancient_" . $rune->ancient . "'>\n";
  174. $html .= "<img class='rune_base' src='" . URL::IMG["RUNE"] . "base.png'/>\n";
  175. $html .= "<img class='rune_icon' src='" . $rune->type->get_image() . "'/>\n";
  176. $html .= "<span class='rune_stars'>\n";
  177. $star_color = "gold";
  178. if ($rune->level == 15){
  179. $star_color = "purple";
  180. }
  181. for ($i = 0; $i < $rune->stars; $i ++){
  182. $html .= "<img class='star star_$star_color' src='" . URL::IMG["ICON"] . "star.png'/>\n";
  183. }
  184. $html .= "</span>\n";
  185. $html .= "<span class='rune_level'>\n";
  186. $html .= $rune->level . "\n";
  187. $html .= "</span>\n";
  188. $html .= "</div>\n";
  189. if ($unit instanceof Unit){
  190. $html .= "<div class='assigned'>\n";
  191. $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
  192. $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
  193. $html .= "</a>\n";
  194. $html .= "</div>\n";
  195. }
  196. return $html;
  197. }
  198. /**
  199. * Generates a rune table.
  200. *
  201. * @param Rune rune Entity to get the info from.
  202. * @param Unit unit Optional. The unit the rune is assigned to.
  203. * @return string HTML content for a rune table. Empty on error.
  204. */
  205. public static function rune_table($rune, $unit = null) {
  206. if (!($rune instanceof Rune)){
  207. return "";
  208. }
  209. $html = "";
  210. $html .= "<table class='rune' id='rune-" . $rune->id . "'>\n";
  211. $html .= "<tr>\n";
  212. $html .= "<td class='icon'>\n";
  213. $html .= HTML::rune_panel($rune, $unit) . "\n";
  214. $html .= "</td>\n";
  215. $html .= "<td class='stats'>\n";
  216. $html .= "<table>\n";
  217. // Main stat
  218. $html .= "<tr class='main_stat'>\n";
  219. $html .= "<td class='stat'>\n";
  220. if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  221. $stat_name = str_replace("%", "", $rune->main_stat_name);
  222. $stat_value = "+" . $rune->main_stat_value . "%";
  223. }
  224. else{
  225. $stat_name = $rune->main_stat_name;
  226. $stat_value = "+" . $rune->main_stat_value. "&nbsp;";
  227. }
  228. $html .= $stat_name . "\n";
  229. $html .= "</td>\n";
  230. $html .= "<td class='value'>\n";
  231. $html .= $stat_value . "\n";
  232. $html .= "</td>\n";
  233. $html .= "<td class='grind'>\n";
  234. $html .= "</td>\n";
  235. $html .= "<td class='enchant'>\n";
  236. $html .= "</td>\n";
  237. $html .= "</tr>\n";
  238. // Innate stat
  239. $html .= "<tr class='innate_stat'>\n";
  240. $html .= "<td class='stat'>\n";
  241. if (strlen($rune->innate_stat) == 0){
  242. $stat_name = "&nbsp;";
  243. $stat_value = "";
  244. }
  245. elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  246. $stat_name = str_replace("%", "", $rune->innate_stat_name);
  247. $stat_value = "+" . $rune->innate_stat_value . "%";
  248. }
  249. else{
  250. $stat_name = $rune->innate_stat_name;
  251. $stat_value = "+" . $rune->innate_stat_value. "&nbsp;";;
  252. }
  253. $html .= $stat_name . "\n";
  254. $html .= "</td>\n";
  255. $html .= "<td class='value'>\n";
  256. $html .= $stat_value . "\n";
  257. $html .= "</td>\n";
  258. $html .= "<td class='grind'>\n";
  259. $html .= "</td>\n";
  260. $html .= "</tr>\n";
  261. $substats = array($rune->substat_1, $rune->substat_2, $rune->substat_3, $rune->substat_4);
  262. $substats_name = array($rune->substat_1_name, $rune->substat_2_name, $rune->substat_3_name, $rune->substat_4_name);
  263. $substats_value = array($rune->substat_1_value, $rune->substat_2_value, $rune->substat_3_value, $rune->substat_4_value);
  264. $substats_grind = array($rune->substat_1_grind, $rune->substat_2_grind, $rune->substat_3_grind, $rune->substat_4_grind);
  265. $substats_enchant = array($rune->substat_1_enchant, $rune->substat_2_enchant, $rune->substat_3_enchant, $rune->substat_4_enchant);
  266. for ($i = 0; $i < 4; $i ++){
  267. if (strlen($substats_name[$i]) == 0){
  268. $stat_name = "&nbsp;";
  269. $stat_value = "";
  270. }
  271. elseif (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  272. $stat_name = str_replace("%", "", $substats_name[$i]);
  273. $stat_value = "+" . $substats_value[$i] . "%";
  274. }
  275. else{
  276. $stat_name = $substats_name[$i];
  277. $stat_value = "+" . $substats_value[$i]. "&nbsp;";
  278. }
  279. $grind = "";
  280. if ($substats_grind[$i] > 0){
  281. $grind = "+" . $substats_grind[$i];
  282. if (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  283. $grind = $grind . "%";
  284. }
  285. }
  286. $html .= "<tr class=substat>\n";
  287. $html .= "<td class='stat'>\n";
  288. $html .= $stat_name . "\n";
  289. $html .= "</td>\n";
  290. $html .= "<td class='value'>\n";
  291. $html .= $stat_value . "\n";
  292. $html .= "<td class='grind grind_$grind'>\n";
  293. $html .= $grind . "\n";
  294. if ($substats_enchant[$i] == 1){
  295. $html .= "<img title='Enchanted' src='" . URL::IMG["RUNE"] . "enchanted.png'/>\n";
  296. }
  297. $html .= "</td>\n";
  298. $html .= "</tr>\n";
  299. }
  300. $html .= "</table>\n";
  301. $html .= "</td>\n";
  302. // Details
  303. $html .= "<td class='details'>\n";
  304. $html .= "<table class='table_details'>\n";
  305. $html .= "<tr>\n";
  306. $html .= "<td class='title'>\n";
  307. $html .= "QY.:\n";
  308. $html .= "</td>\n";
  309. $html .= "<td class='value'>\n";
  310. $html .= "<span class='quality quality_" . strtolower($rune->quality_name) . "'>\n";
  311. $html .= $rune->quality_name . "\n";
  312. $html .= "</span>\n";
  313. $html .= "</td>\n";
  314. $html .= "</tr>\n";
  315. $html .= "<tr>\n";
  316. $html .= "<td class='title'>\n";
  317. $html .= "O.QY.:\n";
  318. $html .= "</td>\n";
  319. $html .= "<td class='value'>\n";
  320. $html .= "<span class='quality quality_" . strtolower($rune->original_quality_name) . "'>\n";
  321. $html .= $rune->original_quality_name . "\n";
  322. $html .= "</span>\n";
  323. $html .= "</td>\n";
  324. $html .= "</tr>\n";
  325. $html .= "<tr>\n";
  326. $html .= "<td class='title'>\n";
  327. $html .= "Value:\n";
  328. $html .= "</td>\n";
  329. $html .= "<td class='value'>\n";
  330. $html .= number_format($rune->value, 0, ".", ",") . "\n";
  331. $html .= "</td>\n";
  332. $html .= "</tr>\n";
  333. $html .= "<tr>\n";
  334. $html .= "<td class='title'>\n";
  335. $html .= "EFF.:\n";
  336. $html .= "</td>\n";
  337. $html .= "<td class='value'>\n";
  338. $html .= number_format($rune->efficiency, 2, ".", ",") . "%\n";
  339. $html .= "</td>\n";
  340. $html .= "</tr>\n";
  341. $html .= "<tr>\n";
  342. $html .= "<td class='title'>\n";
  343. $html .= "MX.E.:\n";
  344. $html .= "</td>\n";
  345. $html .= "<td class='value'>\n";
  346. $html .= number_format($rune->max_efficiency, 2, ".", ",") . "%\n";
  347. $html .= "</td>\n";
  348. $html .= "</tr>\n";
  349. $html .= "</table>\n";
  350. $html .= "</td>\n";
  351. $html .= "</tr>\n";
  352. $html .= "</table>\n";
  353. return $html;
  354. }
  355. // TODO: Icon and background selection must go in the entity code.
  356. /**
  357. * Generates an artifact panel.
  358. *
  359. * @param Artifact artifact Entity to get the info from.
  360. * @param Unit unit Optional. The unit the artifact is assigned to.
  361. * @return string HTML content for an artifact panel. Empty on error.
  362. */
  363. public static function artifact_panel($artifact, $unit = null) {
  364. if (!($artifact instanceof Artifact)){
  365. return "";
  366. }
  367. $html = "";
  368. $html .= "<div class='artifact_panel artifact_level_" . $artifact->level . " artifact_quality_" . strtolower($artifact->quality_name) . " artifact_original_quality_" . strtolower($artifact->original_quality_name) . " '>\n";
  369. $background = "";
  370. $icon = "";
  371. if ($artifact->type == ARTIFACT_TYPE::ARCHETYPE){
  372. $background = URL::IMG["ARTIFACT"] . "type_" . strtolower($artifact->quality_name) . ".png";
  373. $icon = URL::IMG["ARTIFACT"] . "type_";
  374. switch ($artifact->type){
  375. case ARCHETYPE_ID::ATTACK:
  376. $icon .= "attack";
  377. break;
  378. case ARCHETYPE_ID::DEFENSE:
  379. $icon .= "defense";
  380. break;
  381. case ARCHETYPE_ID::HP:
  382. $icon .= "hp";
  383. break;
  384. case ARCHETYPE_ID::SUPPORT:
  385. $icon .= "support";
  386. break;
  387. }
  388. $icon .= ".png";
  389. }
  390. else{
  391. $background = URL::IMG["ARTIFACT"] . "element_" . strtolower($artifact->quality_name) . ".png";
  392. $icon = URL::IMG["ARTIFACT"] . "element_";
  393. switch ($artifact->element){
  394. case ELEMENT_ID::WATER:
  395. $icon .= "water";
  396. break;
  397. case ELEMENT_ID::WIND:
  398. $icon .= "wind";
  399. break;
  400. case ELEMENT_ID::FIRE:
  401. $icon .= "fire";
  402. break;
  403. case ELEMENT_ID::LIGHT:
  404. $icon .= "light";
  405. break;
  406. case ELEMENT_ID::DARK:
  407. $icon .= "dark";
  408. break;
  409. }
  410. $icon .= ".png";
  411. }
  412. $html .= "<img class='artifact_base' src='" . $background . "'/>\n";
  413. $html .= "<img class='artifact_icon' src='" . $icon . "'/>\n";
  414. $html .= "<span class='artifact_stars'>\n";
  415. $html .= "</span>\n";
  416. $html .= "<span class='artifact_level'>\n";
  417. $html .= $artifact->level . "\n";
  418. $html .= "</span>\n";
  419. $html .= "</div>\n";
  420. if ($unit instanceof Unit){
  421. $html .= "<div class='assigned'>\n";
  422. $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
  423. $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
  424. $html .= "</a>\n";
  425. $html .= "</div>\n";
  426. }
  427. return $html;
  428. }
  429. /**
  430. * Generates a artifact table.
  431. *
  432. * @param Artifact artifact Entity to get the info from.
  433. * @param Unit unit Optional. The unit the artifact is assigned to.
  434. * @return string HTML content for a artifact table. Empty on error.
  435. */
  436. public static function artifact_table($artifact, $unit = null) {
  437. if (!($artifact instanceof Artifact)){
  438. return "";
  439. }
  440. $html = "";
  441. $html .= "<table class='artifact' id='artifact-" . $artifact->id . "'>\n";
  442. $html .= "<tr>\n";
  443. $html .= "<td class='icon'>\n";
  444. $html .= HTML::artifact_panel($artifact, $unit) . "\n";
  445. $html .= "</td>\n";
  446. $html .= "<td class='effects'>\n";
  447. $html .= "<table>\n";
  448. // Main stat
  449. $html .= "<tr class='effect main_stat'>\n";
  450. $html .= "<td class='effect'>\n";
  451. $stat_name = $artifact->main_stat_name;
  452. $stat_value = "+" . $artifact->main_stat_value;
  453. $html .= $stat_name . "\n";
  454. $html .= $stat_value . "\n";
  455. $html .= "</td>\n";
  456. $html .= "</tr>\n";
  457. $effects = array($artifact->effect_1_description, $artifact->effect_2_description, $artifact->effect_3_description, $artifact->effect_4_description);
  458. for ($i = 0; $i < 4; $i ++){
  459. $html .= "<tr class='effect'>\n";
  460. $html .= "<td class='effect'>\n";
  461. $name = $effects[$i];
  462. $name = str_replace("Increasing", "Inc.", $name);
  463. $name = str_replace("Decrease", "Dec.", $name);
  464. $name = str_replace("Critical", "Crit.", $name);
  465. $name = str_replace("Received ", "", $name);
  466. $name = str_replace("Damage", "Dmg.", $name);
  467. $name = str_replace("Additional", "Addl.", $name);
  468. $name = str_replace("Proportional", "Rel.", $name);
  469. $name = str_replace("Counterattack", "Counter", $name);
  470. $name = str_replace("Dealt by Attacking Together", "Attacking Together", $name);
  471. $html .= $name;
  472. $html .= "</td>\n";
  473. $html .= "</tr>\n";
  474. }
  475. $html .= "</table>\n";
  476. $html .= "</td>\n";
  477. // Details
  478. /* TODO: Only quaity data, and for that the icon is enough
  479. $html .= "<td class='details'>\n";
  480. $html .= "<table class='table_details'>\n";
  481. $html .= "<tr>\n";
  482. $html .= "<td class='title'>\n";
  483. $html .= "Quality:\n";
  484. $html .= "</td>\n";
  485. $html .= "<td class='value'>\n";
  486. $html .= "<span class='quality quality_" . strtolower($artifact->quality_name) . "'>\n";
  487. $html .= $artifact->quality_name . "\n";
  488. $html .= "</span>\n";
  489. $html .= "</td>\n";
  490. $html .= "</tr>\n";
  491. $html .= "<tr>\n";
  492. $html .= "<td class='title'>\n";
  493. $html .= "Original q.:\n";
  494. $html .= "</td>\n";
  495. $html .= "<td class='value'>\n";
  496. $html .= "<span class='quality quality_" . strtolower($artifact->original_quality_name) . "'>\n";
  497. $html .= $artifact->original_quality_name . "\n";
  498. $html .= "</span>\n";
  499. $html .= "</td>\n";
  500. $html .= "</tr>\n";
  501. $html .= "<tr>\n";
  502. $html .= "<td class='title'>\n";
  503. // TODO: No data on value yet
  504. $html .= ""; //"Value:\n";
  505. $html .= "</td>\n";
  506. $html .= "<td class='value'>\n";
  507. // TODO: No data on value yet
  508. $html .= ""; //number_format($artifact->value, 0, ".", ",") . "\n";
  509. $html .= "</td>\n";
  510. $html .= "</tr>\n";
  511. $html .= "<tr>\n";
  512. $html .= "<td class='title'>\n";
  513. // TODO: No data on efficiencies yet
  514. $html .= ""; //"Efficiency:\n";
  515. $html .= "</td>\n";
  516. $html .= "<td class='value'>\n";
  517. // TODO: No data on efficiencies yet
  518. $html .= ""; //number_format($artifact->efficiency, 2, ".", ",") . "%\n";
  519. $html .= "</td>\n";
  520. $html .= "</tr>\n";
  521. $html .= "<tr>\n";
  522. $html .= "<td class='title'>\n";
  523. // TODO: No data on efficiencies yet
  524. $html .= ""; //"Max. eff.:\n";
  525. $html .= "</td>\n";
  526. $html .= "<td class='value'>\n";
  527. // TODO: No data on efficiencies yet
  528. $html .= ""; //number_format($artifact->max_efficiency, 2, ".", ",") . "%\n";
  529. $html .= "</td>\n";
  530. $html .= "</tr>\n";
  531. $html .= "<tr>\n";
  532. $html .= "<td class='title'>\n";
  533. // TODO: No data on efficiencies yet
  534. $html .= ""; //"Reached. eff.:\n";
  535. $html .= "</td>\n";
  536. $html .= "<td class='value'>\n";
  537. // TODO: No data on efficiencies yet
  538. $html .= ""; //number_format($artifact->efficiency * 100 / $artifact->max_efficiency, 2, ".", ",") . "%\n";
  539. $html .= "</td>\n";
  540. $html .= "</tr>\n";
  541. $html .= "</table>\n";
  542. */
  543. $html .= "</td>\n";
  544. $html .= "</tr>\n";
  545. $html .= "</table>\n";
  546. return $html;
  547. }
  548. /**
  549. * Generates a grindstone or gem panel.
  550. *
  551. * @param Enchantment Entity to get the info from.
  552. * @return string HTML content for a rune panel. Empty on error.
  553. */
  554. public static function enchantment_panel($enchantment) {
  555. if (!($enchantment instanceof Enchantment)){
  556. return "";
  557. }
  558. $html = "";
  559. if ($enchantment->gem == 1){
  560. if ($enchantment->inmemorial == 1){
  561. $base = URL::IMG["GRIND"] . "gem_inmemorial.png";
  562. }
  563. else{
  564. $base = URL::IMG["GRIND"] . "gem.png";
  565. }
  566. }
  567. else{
  568. if ($enchantment->inmemorial == 1){
  569. $base = URL::IMG["GRIND"] . "grind_inmemorial.png";
  570. }
  571. else{
  572. $base = URL::IMG["GRIND"] . "grind.png";
  573. }
  574. }
  575. if ($enchantment->inmemorial == 0 && isset($enchantment->rune)){
  576. $icon = "<img class='enchantment_icon' src='" . $enchantment->rune->get_image() . "'/>\n";
  577. }
  578. else{
  579. $icon = "";
  580. }
  581. if (in_array($enchantment->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  582. $stat_name = str_replace("%", "", $enchantment->stat_name);
  583. $stat_value = "+" . $enchantment->min . "~" . $enchantment->max . "%";
  584. }
  585. else{
  586. $stat_name = $enchantment->stat_name;
  587. $stat_value = "+" . $enchantment->min . "~" . $enchantment->max;
  588. }
  589. $html .= "<div class='enchantment_panel enchantment_quality_" . strtolower($enchantment->quality_name) . " enchantment_ancient_" . $enchantment->ancient . "'>\n";
  590. $html .= "<img class='enchantment_base' src='" . $base . "'/>\n";
  591. $html .= $icon;
  592. $html .= "<span class='enchantment_stat'>\n";
  593. $html .= "<span class='enchantment_stat_name'>" . $stat_name . "</span>\n";
  594. $html .= "<span class='enchantment_stat_value'>" . $stat_value . "</span>\n";
  595. $html .= "</span>\n";
  596. if ($enchantment->amount > 0){
  597. $html .= "<span class='enchantment_amount'>\n";
  598. $html .= "x" . $enchantment->amount . "\n";
  599. $html .= "</span>\n";
  600. }
  601. $html .= "</div>\n";
  602. return $html;
  603. }
  604. /**
  605. * Generates a building panel.
  606. *
  607. * @param Building|Decoration|K_Building|K_Decoration $building Entity to get the info from.
  608. * @return string HTML content for a building panel. Empty on error.
  609. */
  610. public static function building_panel($building) {
  611. if ($building instanceof Building){
  612. $level = false;
  613. $title = $building->building->name;
  614. $description = $building->building->description;
  615. $img = $building->building->get_image();
  616. }
  617. elseif ($building instanceof K_Building){
  618. $level = false;
  619. $title = $building->name;
  620. $description = $building->building->description;
  621. $img = $building->get_image();
  622. }
  623. elseif ($building instanceof Decoration){
  624. $level = $building->level;
  625. $title = $building->decoration->name;
  626. $description = $building->decoration->description;
  627. $img = $building->decoration->get_image();
  628. }
  629. elseif ($building instanceof K_Decoration){
  630. $level = false;
  631. $title = $building->name;
  632. $description = $building->building->description;
  633. $img = $building->get_image();
  634. }
  635. else{
  636. return "";
  637. }
  638. if (strlen($description) > 0){
  639. $title .= ": " . $description;
  640. }
  641. $html = "<div class='building_panel'>\n";
  642. $html .= "<img title='" . $title . "' class='building' src='" . $img . "'/>\n";
  643. if ($level){
  644. $html .= "<span class='level'>\n";
  645. $html .= $level . "\n";
  646. $html .= "</span>\n";
  647. }
  648. $html .= "</div>\n";
  649. return $html;
  650. }
  651. /**
  652. * Generates a item panel.
  653. *
  654. * @param Inventory $item Entity to get the info from.
  655. * @return string HTML content for an item panel. Empty on error.
  656. */
  657. public static function item_panel($item) {
  658. if (!($item instanceof Inventory)){
  659. return "";
  660. }
  661. $html = "<div class='item_panel'>\n";
  662. $html .= "<img title='" . $item->name . "' class='item' src='" . $item->get_image() . "'/>\n";
  663. $html .= "<span class='amount'>\n";
  664. $html .= $item->amount . "\n";
  665. $html .= "</span>\n";
  666. $html .= "</div>\n";
  667. return $html;
  668. }
  669. /**
  670. * Generates a source panel.
  671. *
  672. * @param Inventory $source Entity to get the info from.
  673. * @return string HTML content for a source panel. Empty on error.
  674. */
  675. public static function source_panel($source) {
  676. //if (!($item instanceof K_Source)){
  677. // return "";
  678. //}
  679. $html = "<div class='source_panel'>\n";
  680. $html .= "<img title='" . $source->name . "' class='item' src='" . $source->get_image() . "'/>\n";
  681. $html .= "</div>\n";
  682. return $html;
  683. }
  684. /**
  685. * Generates an arena rank icon image.
  686. *
  687. * @param int $d Arena rank id.
  688. * @return string HTML content for the image.
  689. */
  690. public static function arena_rank_icon($id) {
  691. switch ($id){
  692. case ARENA_RANK_ID::BEGINER:
  693. $src = URL::IMG["RANK"] . "0901.png";
  694. $tit = "Beginer";
  695. break;
  696. case ARENA_RANK_ID::CHALLENGER_1:
  697. $src = URL::IMG["RANK"] . "1001.png";
  698. $tit = "Challenger 1";
  699. break;
  700. case ARENA_RANK_ID::CHALLENGER_2:
  701. $src = URL::IMG["RANK"] . "1002.png";
  702. $tit = "Challenger 2";
  703. break;
  704. case ARENA_RANK_ID::CHALLENGER_3:
  705. $src = URL::IMG["RANK"] . "1003.png";
  706. $tit = "Challenger 3";
  707. break;
  708. case ARENA_RANK_ID::FIGHTER_1:
  709. $src = URL::IMG["RANK"] . "2001.png";
  710. $tit = "Fighter 1";
  711. break;
  712. case ARENA_RANK_ID::FIGHTER_2:
  713. $src = URL::IMG["RANK"] . "2002.png";
  714. $tit = "Fighter 2";
  715. break;
  716. case ARENA_RANK_ID::FIGHTER_3:
  717. $src = URL::IMG["RANK"] . "2003.png";
  718. $tit = "Fighter 3";
  719. break;
  720. case ARENA_RANK_ID::CONQUEROR_1:
  721. $src = URL::IMG["RANK"] . "3001.png";
  722. $tit = "Conqueror 1";
  723. break;
  724. case ARENA_RANK_ID::CONQUEROR_2:
  725. $src = URL::IMG["RANK"] . "3002.png";
  726. $tit = "Conqueror 2";
  727. break;
  728. case ARENA_RANK_ID::CONQUEROR_3:
  729. $src = URL::IMG["RANK"] . "3003.png";
  730. $tit = "Conqueror 3";
  731. break;
  732. case ARENA_RANK_ID::GUARDIAN_1:
  733. $src = URL::IMG["RANK"] . "4001.png";
  734. $tit = "Guardian 1";
  735. break;
  736. case ARENA_RANK_ID::GUARDIAN_2:
  737. $src = URL::IMG["RANK"] . "4002.png";
  738. $tit = "Guardian 2";
  739. break;
  740. case ARENA_RANK_ID::GUARDIAN_3:
  741. $src = URL::IMG["RANK"] . "4003.png";
  742. $tit = "Guardian 3";
  743. break;
  744. case ARENA_RANK_ID::LEGEND:
  745. $src = URL::IMG["RANK"] . "5001.png";
  746. $tit = "Legend";
  747. default:
  748. $src = URL::IMG["RANK"] . $id . ".png";
  749. }
  750. $html = "<img alt='$tit' title='$tit' src='$src'/>";
  751. return $html;
  752. }
  753. }
  754. ?>