HTML_Helper.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  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->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  221. $stat_name = str_replace("%", "", $rune->main_stat->stat_name);
  222. $stat_value = "+" . $rune->main_stat->value . "%";
  223. }
  224. else{
  225. $stat_name = $rune->main_stat->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 ($rune->innate_stat == null){
  242. $stat_name = "&nbsp;";
  243. $stat_value = "";
  244. }
  245. elseif (in_array($rune->innate_stat->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  246. $stat_name = str_replace("%", "", $rune->innate_stat->stat_name);
  247. $stat_value = "+" . $rune->innate_stat->value . "%";
  248. }
  249. else{
  250. $stat_name = $rune->innate_stat->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. for ($i = 0; $i < 4; $i ++){
  262. if ($rune->substats[$i] == null){
  263. $stat_name = "&nbsp;";
  264. $stat_value = "";
  265. }
  266. elseif (in_array($rune->substats[$i]->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  267. $stat_name = str_replace("%", "", $rune->substats[$i]->stat_name);
  268. $stat_value = "+" . $rune->substats[$i]->value . "%";
  269. }
  270. else{
  271. $stat_name = $rune->substats[$i]->stat_name;
  272. $stat_value = "+" . $rune->substats[$i]->value. "&nbsp;";
  273. }
  274. $grind = "";
  275. if ($rune->substats[$i] != null && $rune->substats[$i]->grind > 0){
  276. $grind = "+" . $rune->substats[$i]->grind;
  277. if (in_array($rune->substats[$i]->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  278. $grind = $grind . "%";
  279. }
  280. }
  281. $html .= "<tr class=substat>\n";
  282. $html .= "<td class='stat'>\n";
  283. $html .= $stat_name . "\n";
  284. $html .= "</td>\n";
  285. $html .= "<td class='value'>\n";
  286. $html .= $stat_value . "\n";
  287. $html .= "<td class='grind grind_$grind'>\n";
  288. $html .= $grind . "\n";
  289. if ($rune->substats[$i] != null && $rune->substats[$i]->enchant == 1){
  290. $html .= "<img title='Enchanted' src='" . URL::IMG["RUNE"] . "enchanted.png'/>\n";
  291. }
  292. $html .= "</td>\n";
  293. $html .= "</tr>\n";
  294. }
  295. $html .= "</table>\n";
  296. $html .= "</td>\n";
  297. // Details
  298. $html .= "<td class='details'>\n";
  299. $html .= "<table class='table_details'>\n";
  300. $html .= "<tr>\n";
  301. $html .= "<td class='title'>\n";
  302. $html .= "QY.:\n";
  303. $html .= "</td>\n";
  304. $html .= "<td class='value'>\n";
  305. $html .= "<span class='quality quality_" . strtolower($rune->quality_name) . "'>\n";
  306. $html .= $rune->quality_name . "\n";
  307. $html .= "</span>\n";
  308. $html .= "</td>\n";
  309. $html .= "</tr>\n";
  310. $html .= "<tr>\n";
  311. $html .= "<td class='title'>\n";
  312. $html .= "O.QY.:\n";
  313. $html .= "</td>\n";
  314. $html .= "<td class='value'>\n";
  315. $html .= "<span class='quality quality_" . strtolower($rune->original_quality_name) . "'>\n";
  316. $html .= $rune->original_quality_name . "\n";
  317. $html .= "</span>\n";
  318. $html .= "</td>\n";
  319. $html .= "</tr>\n";
  320. $html .= "<tr>\n";
  321. $html .= "<td class='title'>\n";
  322. $html .= "Value:\n";
  323. $html .= "</td>\n";
  324. $html .= "<td class='value'>\n";
  325. $html .= number_format($rune->value, 0, ".", ",") . "\n";
  326. $html .= "</td>\n";
  327. $html .= "</tr>\n";
  328. $html .= "<tr>\n";
  329. $html .= "<td class='title'>\n";
  330. $html .= "EFF.:\n";
  331. $html .= "</td>\n";
  332. $html .= "<td class='value'>\n";
  333. $html .= number_format($rune->efficiency, 2, ".", ",") . "%\n";
  334. $html .= "</td>\n";
  335. $html .= "</tr>\n";
  336. $html .= "<tr>\n";
  337. $html .= "<td class='title'>\n";
  338. $html .= "MX.E.:\n";
  339. $html .= "</td>\n";
  340. $html .= "<td class='value'>\n";
  341. $html .= number_format($rune->max_efficiency, 2, ".", ",") . "%\n";
  342. $html .= "</td>\n";
  343. $html .= "</tr>\n";
  344. $html .= "</table>\n";
  345. $html .= "</td>\n";
  346. $html .= "</tr>\n";
  347. $html .= "</table>\n";
  348. return $html;
  349. }
  350. // TODO: Icon and background selection must go in the entity code.
  351. /**
  352. * Generates an artifact panel.
  353. *
  354. * @param Artifact artifact Entity to get the info from.
  355. * @param Unit unit Optional. The unit the artifact is assigned to.
  356. * @return string HTML content for an artifact panel. Empty on error.
  357. */
  358. public static function artifact_panel($artifact, $unit = null) {
  359. if (!($artifact instanceof Artifact)){
  360. return "";
  361. }
  362. $html = "";
  363. $html .= "<div class='artifact_panel artifact_level_" . $artifact->level . " artifact_quality_" . strtolower($artifact->quality_name) . " artifact_original_quality_" . strtolower($artifact->original_quality_name) . " '>\n";
  364. $background = "";
  365. $icon = "";
  366. if ($artifact->type == ARTIFACT_TYPE::ARCHETYPE){
  367. $background = URL::IMG["ARTIFACT"] . "type_" . strtolower($artifact->quality_name) . ".png";
  368. $icon = URL::IMG["ARTIFACT"] . "type_";
  369. switch ($artifact->type){
  370. case ARCHETYPE_ID::ATTACK:
  371. $icon .= "attack";
  372. break;
  373. case ARCHETYPE_ID::DEFENSE:
  374. $icon .= "defense";
  375. break;
  376. case ARCHETYPE_ID::HP:
  377. $icon .= "hp";
  378. break;
  379. case ARCHETYPE_ID::SUPPORT:
  380. $icon .= "support";
  381. break;
  382. }
  383. $icon .= ".png";
  384. }
  385. else{
  386. $background = URL::IMG["ARTIFACT"] . "element_" . strtolower($artifact->quality_name) . ".png";
  387. $icon = URL::IMG["ARTIFACT"] . "element_";
  388. switch ($artifact->element){
  389. case ELEMENT_ID::WATER:
  390. $icon .= "water";
  391. break;
  392. case ELEMENT_ID::WIND:
  393. $icon .= "wind";
  394. break;
  395. case ELEMENT_ID::FIRE:
  396. $icon .= "fire";
  397. break;
  398. case ELEMENT_ID::LIGHT:
  399. $icon .= "light";
  400. break;
  401. case ELEMENT_ID::DARK:
  402. $icon .= "dark";
  403. break;
  404. }
  405. $icon .= ".png";
  406. }
  407. $html .= "<img class='artifact_base' src='" . $background . "'/>\n";
  408. $html .= "<img class='artifact_icon' src='" . $icon . "'/>\n";
  409. $html .= "<span class='artifact_stars'>\n";
  410. $html .= "</span>\n";
  411. $html .= "<span class='artifact_level'>\n";
  412. $html .= $artifact->level . "\n";
  413. $html .= "</span>\n";
  414. $html .= "</div>\n";
  415. if ($unit instanceof Unit){
  416. $html .= "<div class='assigned'>\n";
  417. $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
  418. $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
  419. $html .= "</a>\n";
  420. $html .= "</div>\n";
  421. }
  422. return $html;
  423. }
  424. /**
  425. * Generates a artifact table.
  426. *
  427. * @param Artifact artifact Entity to get the info from.
  428. * @param Unit unit Optional. The unit the artifact is assigned to.
  429. * @return string HTML content for a artifact table. Empty on error.
  430. */
  431. public static function artifact_table($artifact, $unit = null) {
  432. if (!($artifact instanceof Artifact)){
  433. return "";
  434. }
  435. $html = "";
  436. $html .= "<table class='artifact' id='artifact-" . $artifact->id . "'>\n";
  437. $html .= "<tr>\n";
  438. $html .= "<td class='icon'>\n";
  439. $html .= HTML::artifact_panel($artifact, $unit) . "\n";
  440. $html .= "</td>\n";
  441. $html .= "<td class='effects'>\n";
  442. $html .= "<table>\n";
  443. // Main stat
  444. $html .= "<tr class='effect main_stat'>\n";
  445. $html .= "<td class='effect'>\n";
  446. $stat_name = $artifact->stat->name;
  447. $stat_value = "+" . $artifact->stat->value;
  448. $html .= $stat_name . "\n";
  449. $html .= $stat_value . "\n";
  450. $html .= "</td>\n";
  451. $html .= "</tr>\n";
  452. //$effects = array($artifact->effect_1_description, $artifact->effect_2_description, $artifact->effect_3_description, $artifact->effect_4_description);
  453. for ($i = 0; $i < 4; $i ++){
  454. $html .= "<tr class='effect'>\n";
  455. $html .= "<td class='effect'>\n";
  456. if (count($artifact->effects) <= $i){
  457. $name = "&nbsp;";
  458. }
  459. else{
  460. $name = $artifact->effects[$i]->name;
  461. $name = str_replace("Increasing", "Inc.", $name);
  462. $name = str_replace("Decrease", "Dec.", $name);
  463. $name = str_replace("Critical", "Crit.", $name);
  464. $name = str_replace("Received ", "", $name);
  465. $name = str_replace("Damage", "Dmg.", $name);
  466. $name = str_replace("Additional", "Addl.", $name);
  467. $name = str_replace("Proportional", "Rel.", $name);
  468. $name = str_replace("Counterattack", "Counter", $name);
  469. $name = str_replace("Dealt by Attacking Together", "Attacking Together", $name);
  470. $name = str_replace("HP condition is bad", "bad HP", $name);
  471. $name = str_replace("HP condition is good", "good HP", $name);
  472. }
  473. $html .= $name;
  474. $html .= "</td>\n";
  475. $html .= "</tr>\n";
  476. }
  477. $html .= "</table>\n";
  478. $html .= "</td>\n";
  479. $html .= "</tr>\n";
  480. $html .= "<tr>\n";
  481. $html .= "<td class='details' colspan='2'>\n";
  482. $html .= "EFF.: " . number_format($artifact->efficiency, 2, ".", ",") . "%&nbsp;&nbsp;\n";
  483. $html .= "MX.E.: " . number_format($artifact->max_efficiency, 2, ".", ",") . "%&nbsp;&nbsp;\n";
  484. $html .= "Value.: " . number_format($artifact->value, 0, ".", ",") . "\n";
  485. $html .= "</td>\n";
  486. $html .= "</tr>\n";
  487. $html .= "</table>\n";
  488. return $html;
  489. }
  490. /**
  491. * Generates a grindstone or gem panel.
  492. *
  493. * @param Enchantment Entity to get the info from.
  494. * @return string HTML content for a rune panel. Empty on error.
  495. */
  496. public static function enchantment_panel($enchantment) {
  497. if (!($enchantment instanceof Enchantment)){
  498. return "";
  499. }
  500. $html = "";
  501. if ($enchantment->gem == 1){
  502. if ($enchantment->inmemorial == 1){
  503. $base = URL::IMG["GRIND"] . "gem_inmemorial.png";
  504. }
  505. else{
  506. $base = URL::IMG["GRIND"] . "gem.png";
  507. }
  508. }
  509. else{
  510. if ($enchantment->inmemorial == 1){
  511. $base = URL::IMG["GRIND"] . "grind_inmemorial.png";
  512. }
  513. else{
  514. $base = URL::IMG["GRIND"] . "grind.png";
  515. }
  516. }
  517. if ($enchantment->inmemorial == 0 && isset($enchantment->rune)){
  518. $icon = "<img class='enchantment_icon' src='" . $enchantment->rune->get_image() . "'/>\n";
  519. }
  520. else{
  521. $icon = "";
  522. }
  523. if (in_array($enchantment->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  524. $stat_name = str_replace("%", "", $enchantment->stat_name);
  525. $stat_value = "+" . $enchantment->min . "~" . $enchantment->max . "%";
  526. }
  527. else{
  528. $stat_name = $enchantment->stat_name;
  529. $stat_value = "+" . $enchantment->min . "~" . $enchantment->max;
  530. }
  531. $html .= "<div class='enchantment_panel enchantment_quality_" . strtolower($enchantment->quality_name) . " enchantment_ancient_" . $enchantment->ancient . "'>\n";
  532. $html .= "<img class='enchantment_base' src='" . $base . "'/>\n";
  533. $html .= $icon;
  534. $html .= "<span class='enchantment_stat'>\n";
  535. $html .= "<span class='enchantment_stat->stat_name'>" . $stat_name . "</span>\n";
  536. $html .= "<span class='enchantment_stat->value'>" . $stat_value . "</span>\n";
  537. $html .= "</span>\n";
  538. if ($enchantment->amount > 0){
  539. $html .= "<span class='enchantment_amount'>\n";
  540. $html .= "x" . $enchantment->amount . "\n";
  541. $html .= "</span>\n";
  542. }
  543. $html .= "</div>\n";
  544. return $html;
  545. }
  546. /**
  547. * Generates a building panel.
  548. *
  549. * @param Building|Decoration|K_Building|K_Decoration $building Entity to get the info from.
  550. * @return string HTML content for a building panel. Empty on error.
  551. */
  552. public static function building_panel($building) {
  553. if ($building instanceof Building){
  554. $level = false;
  555. $title = $building->building->name;
  556. $description = $building->building->description;
  557. $img = $building->building->get_image();
  558. }
  559. elseif ($building instanceof K_Building){
  560. $level = false;
  561. $title = $building->name;
  562. $description = $building->building->description;
  563. $img = $building->get_image();
  564. }
  565. elseif ($building instanceof Decoration){
  566. $level = $building->level;
  567. $title = $building->decoration->name;
  568. $description = $building->decoration->description;
  569. $img = $building->decoration->get_image();
  570. }
  571. elseif ($building instanceof K_Decoration){
  572. $level = false;
  573. $title = $building->name;
  574. $description = $building->building->description;
  575. $img = $building->get_image();
  576. }
  577. else{
  578. return "";
  579. }
  580. if (strlen($description) > 0){
  581. $title .= ": " . $description;
  582. }
  583. $html = "<div class='building_panel'>\n";
  584. $html .= "<img title='" . $title . "' class='building' src='" . $img . "'/>\n";
  585. if ($level){
  586. $html .= "<span class='level'>\n";
  587. $html .= $level . "\n";
  588. $html .= "</span>\n";
  589. }
  590. $html .= "</div>\n";
  591. return $html;
  592. }
  593. /**
  594. * Generates a item panel.
  595. *
  596. * @param Inventory $item Entity to get the info from.
  597. * @return string HTML content for an item panel. Empty on error.
  598. */
  599. public static function item_panel($item) {
  600. if (!($item instanceof Inventory)){
  601. return "";
  602. }
  603. $html = "<div class='item_panel'>\n";
  604. $html .= "<img title='" . $item->name . "' class='item' src='" . $item->get_image() . "'/>\n";
  605. $html .= "<span class='amount'>\n";
  606. $html .= $item->amount . "\n";
  607. $html .= "</span>\n";
  608. $html .= "</div>\n";
  609. return $html;
  610. }
  611. /**
  612. * Generates a source panel.
  613. *
  614. * @param Inventory $source Entity to get the info from.
  615. * @return string HTML content for a source panel. Empty on error.
  616. */
  617. public static function source_panel($source) {
  618. //if (!($item instanceof K_Source)){
  619. // return "";
  620. //}
  621. $html = "<div class='source_panel'>\n";
  622. $html .= "<img title='" . $source->name . "' class='item' src='" . $source->get_image() . "'/>\n";
  623. $html .= "</div>\n";
  624. return $html;
  625. }
  626. /**
  627. * Generates an arena rank icon image.
  628. *
  629. * @param int $d Arena rank id.
  630. * @return string HTML content for the image.
  631. */
  632. public static function arena_rank_icon($id) {
  633. switch ($id){
  634. case ARENA_RANK_ID::BEGINER:
  635. $src = URL::IMG["RANK"] . "0901.png";
  636. $tit = "Beginer";
  637. break;
  638. case ARENA_RANK_ID::CHALLENGER_1:
  639. $src = URL::IMG["RANK"] . "1001.png";
  640. $tit = "Challenger 1";
  641. break;
  642. case ARENA_RANK_ID::CHALLENGER_2:
  643. $src = URL::IMG["RANK"] . "1002.png";
  644. $tit = "Challenger 2";
  645. break;
  646. case ARENA_RANK_ID::CHALLENGER_3:
  647. $src = URL::IMG["RANK"] . "1003.png";
  648. $tit = "Challenger 3";
  649. break;
  650. case ARENA_RANK_ID::FIGHTER_1:
  651. $src = URL::IMG["RANK"] . "2001.png";
  652. $tit = "Fighter 1";
  653. break;
  654. case ARENA_RANK_ID::FIGHTER_2:
  655. $src = URL::IMG["RANK"] . "2002.png";
  656. $tit = "Fighter 2";
  657. break;
  658. case ARENA_RANK_ID::FIGHTER_3:
  659. $src = URL::IMG["RANK"] . "2003.png";
  660. $tit = "Fighter 3";
  661. break;
  662. case ARENA_RANK_ID::CONQUEROR_1:
  663. $src = URL::IMG["RANK"] . "3001.png";
  664. $tit = "Conqueror 1";
  665. break;
  666. case ARENA_RANK_ID::CONQUEROR_2:
  667. $src = URL::IMG["RANK"] . "3002.png";
  668. $tit = "Conqueror 2";
  669. break;
  670. case ARENA_RANK_ID::CONQUEROR_3:
  671. $src = URL::IMG["RANK"] . "3003.png";
  672. $tit = "Conqueror 3";
  673. break;
  674. case ARENA_RANK_ID::GUARDIAN_1:
  675. $src = URL::IMG["RANK"] . "4001.png";
  676. $tit = "Guardian 1";
  677. break;
  678. case ARENA_RANK_ID::GUARDIAN_2:
  679. $src = URL::IMG["RANK"] . "4002.png";
  680. $tit = "Guardian 2";
  681. break;
  682. case ARENA_RANK_ID::GUARDIAN_3:
  683. $src = URL::IMG["RANK"] . "4003.png";
  684. $tit = "Guardian 3";
  685. break;
  686. case ARENA_RANK_ID::LEGEND:
  687. $src = URL::IMG["RANK"] . "5001.png";
  688. $tit = "Legend";
  689. default:
  690. $src = URL::IMG["RANK"] . $id . ".png";
  691. }
  692. $html = "<img alt='$tit' title='$tit' src='$src'/>";
  693. return $html;
  694. }
  695. }
  696. ?>