HTML_Helper.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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 . "Rune_Craft.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. for ($i = 0; $i < $rune->stars; $i ++){
  178. $html .= "<img class='star' src='" . URL::IMG["ICON"] . "star.png'/>\n";
  179. }
  180. $html .= "</span>\n";
  181. $html .= "<span class='rune_level'>\n";
  182. $html .= $rune->level . "\n";
  183. $html .= "</span>\n";
  184. $html .= "</div>\n";
  185. if ($unit instanceof Unit){
  186. $html .= "<div class='assigned'>\n";
  187. $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
  188. $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
  189. $html .= "</a>\n";
  190. $html .= "</div>\n";
  191. }
  192. return $html;
  193. }
  194. /**
  195. * Generates a rune table.
  196. *
  197. * @param Rune rune Entity to get the info from.
  198. * @param Unit unit Optional. The unit the rune is assigned to.
  199. * @return string HTML content for a rune table. Empty on error.
  200. */
  201. public static function rune_table($rune, $unit = null) {
  202. if (!($rune instanceof Rune)){
  203. return "";
  204. }
  205. $html = "";
  206. $html .= "<table class='rune' id='rune-" . $rune->id . "'>\n";
  207. $html .= "<tr>\n";
  208. $html .= "<td class='icon'>\n";
  209. $html .= HTML::rune_panel($rune, $unit) . "\n";
  210. $html .= "</td>\n";
  211. $html .= "<td class='stats'>\n";
  212. $html .= "<table>\n";
  213. // Main stat
  214. $html .= "<tr class='main_stat'>\n";
  215. $html .= "<td class='stat'>\n";
  216. if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  217. $stat_name = str_replace("%", "", $rune->main_stat_name);
  218. $stat_value = "+ " . $rune->main_stat_value . "%";
  219. }
  220. else{
  221. $stat_name = $rune->main_stat_name;
  222. $stat_value = "+ " . $rune->main_stat_value;
  223. }
  224. $html .= $stat_name . "\n";
  225. $html .= "</td>\n";
  226. $html .= "<td class='value'>\n";
  227. $html .= $stat_value . "\n";
  228. $html .= "<td>\n";
  229. $html .= "</tr>\n";
  230. // Innate stat
  231. $html .= "<tr class='innate_stat'>\n";
  232. $html .= "<td class='stat'>\n";
  233. if (strlen($rune->innate_stat) == 0){
  234. $stat_name = "&nbsp;";
  235. $stat_value = "";
  236. }
  237. elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  238. $stat_name = str_replace("%", "", $rune->innate_stat_name);
  239. $stat_value = "+ " . $rune->innate_stat_value . "%";
  240. }
  241. else{
  242. $stat_name = $rune->innate_stat_name;
  243. $stat_value = "+ " . $rune->innate_stat_value;
  244. }
  245. $html .= $stat_name . "\n";
  246. $html .= "</td>\n";
  247. $html .= "<td class='value'>\n";
  248. $html .= $stat_value . "\n";
  249. $html .= "<td>\n";
  250. $html .= "</tr>\n";
  251. $substats = array($rune->substat_1, $rune->substat_2, $rune->substat_3, $rune->substat_4);
  252. $substats_name = array($rune->substat_1_name, $rune->substat_2_name, $rune->substat_3_name, $rune->substat_4_name);
  253. $substats_value = array($rune->substat_1_value, $rune->substat_2_value, $rune->substat_3_value, $rune->substat_4_value);
  254. $substats_grind = array($rune->substat_1_grind, $rune->substat_2_grind, $rune->substat_3_grind, $rune->substat_4_grind);
  255. $substats_enchant = array($rune->substat_1_enchant, $rune->substat_2_enchant, $rune->substat_3_enchant, $rune->substat_4_enchant);
  256. for ($i = 0; $i < 4; $i ++){
  257. if (strlen($substats_name[$i]) == 0){
  258. $stat_name = "&nbsp;";
  259. $stat_value = "";
  260. }
  261. elseif (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  262. $stat_name = str_replace("%", "", $substats_name[$i]);
  263. $stat_value = "+ " . $substats_value[$i] . "%";
  264. }
  265. else{
  266. $stat_name = $substats_name[$i];
  267. $stat_value = "+ " . $substats_value[$i];
  268. }
  269. $grind = "";
  270. if ($substats_grind[$i] > 0){
  271. $grind = "+" . $substats_grind[$i];
  272. if (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  273. $grind = $grind . "%";
  274. }
  275. }
  276. $html .= "<tr class=substat>\n";
  277. $html .= "<td class='stat'>\n";
  278. $html .= $stat_name . "\n";
  279. $html .= "</td>\n";
  280. $html .= "<td class='value'>\n";
  281. $html .= $stat_value . "\n";
  282. $html .= "<span class='grind grind_$grind'>\n";
  283. $html .= $grind . "\n";
  284. $html .= "</span>\n";
  285. if ($substats_enchant[$i] == 1){
  286. $html .= "<img title='Enchanted' src='" . URL::IMG["RUNE"] . "enchanted.png'/>\n";
  287. }
  288. $html .= "</td>\n";
  289. $html .= "</tr>\n";
  290. }
  291. $html .= "</table>\n";
  292. $html .= "</td>\n";
  293. // Details
  294. $html .= "<td class='details'>\n";
  295. $html .= "<table class='table_details'>\n";
  296. $html .= "<tr>\n";
  297. $html .= "<td class='title'>\n";
  298. $html .= "Quality:\n";
  299. $html .= "</td>\n";
  300. $html .= "<td class='value'>\n";
  301. $html .= "<span class='quality quality_" . strtolower($rune->quality_name) . "'>\n";
  302. $html .= $rune->quality_name . "\n";
  303. $html .= "</span>\n";
  304. $html .= "</td>\n";
  305. $html .= "</tr>\n";
  306. $html .= "<tr>\n";
  307. $html .= "<td class='title'>\n";
  308. $html .= "Original q.:\n";
  309. $html .= "</td>\n";
  310. $html .= "<td class='value'>\n";
  311. $html .= "<span class='quality quality_" . strtolower($rune->original_quality_name) . "'>\n";
  312. $html .= $rune->original_quality_name . "\n";
  313. $html .= "</span>\n";
  314. $html .= "</td>\n";
  315. $html .= "</tr>\n";
  316. $html .= "<tr>\n";
  317. $html .= "<td class='title'>\n";
  318. $html .= "Value:\n";
  319. $html .= "</td>\n";
  320. $html .= "<td class='value'>\n";
  321. $html .= number_format($rune->value, 0, ".", ",") . "\n";
  322. $html .= "</td>\n";
  323. $html .= "</tr>\n";
  324. $html .= "<tr>\n";
  325. $html .= "<td class='title'>\n";
  326. $html .= "Efficiency:\n";
  327. $html .= "</td>\n";
  328. $html .= "<td class='value'>\n";
  329. $html .= number_format($rune->efficiency, 2, ".", ",") . "%\n";
  330. $html .= "</td>\n";
  331. $html .= "</tr>\n";
  332. $html .= "<tr>\n";
  333. $html .= "<td class='title'>\n";
  334. $html .= "Max. eff.:\n";
  335. $html .= "</td>\n";
  336. $html .= "<td class='value'>\n";
  337. $html .= number_format($rune->max_efficiency, 2, ".", ",") . "%\n";
  338. $html .= "</td>\n";
  339. $html .= "</tr>\n";
  340. $html .= "<tr>\n";
  341. $html .= "<td class='title'>\n";
  342. $html .= "Reached. eff.:\n";
  343. $html .= "</td>\n";
  344. $html .= "<td class='value'>\n";
  345. $html .= number_format($rune->efficiency * 100 / $rune->max_efficiency, 2, ".", ",") . "%\n";
  346. $html .= "</td>\n";
  347. $html .= "</tr>\n";
  348. $html .= "</table>\n";
  349. $html .= "</td>\n";
  350. $html .= "</tr>\n";
  351. $html .= "</table>\n";
  352. return $html;
  353. }
  354. // TODO: Icon and background selection must go in the entity code.
  355. /**
  356. * Generates an artifact panel.
  357. *
  358. * @param Artifact artifact Entity to get the info from.
  359. * @param Unit unit Optional. The unit the artifact is assigned to.
  360. * @return string HTML content for an artifact panel. Empty on error.
  361. */
  362. public static function artifact_panel($artifact, $unit = null) {
  363. if (!($artifact instanceof Artifact)){
  364. return "";
  365. }
  366. $html = "";
  367. $html .= "<div class='artifact_panel artifact_level_" . $artifact->level . " artifact_quality_" . strtolower($artifact->quality_name) . " artifact_original_quality_" . strtolower($artifact->original_quality_name) . " '>\n";
  368. $background = "";
  369. $icon = "";
  370. if ($artifact->type == ARTIFACT_TYPE::ARCHETYPE){
  371. $background = URL::IMG["ARTIFACT"] . "type_" . strtolower($artifact->quality_name) . ".png";
  372. $icon = URL::IMG["ARTIFACT"] . "type_";
  373. switch ($artifact->type){
  374. case ARCHETYPE_ID::ATTACK:
  375. $icon .= "attack";
  376. break;
  377. case ARCHETYPE_ID::DEFENSE:
  378. $icon .= "defense";
  379. break;
  380. case ARCHETYPE_ID::HP:
  381. $icon .= "hp";
  382. break;
  383. case ARCHETYPE_ID::SUPPORT:
  384. $icon .= "support";
  385. break;
  386. }
  387. $icon .= ".png";
  388. }
  389. else{
  390. $background = URL::IMG["ARTIFACT"] . "element_" . strtolower($artifact->quality_name) . ".png";
  391. $icon = URL::IMG["ARTIFACT"] . "element_";
  392. switch ($artifact->element){
  393. case ELEMENT_ID::WATER:
  394. $icon .= "water";
  395. break;
  396. case ELEMENT_ID::WIND:
  397. $icon .= "wind";
  398. break;
  399. case ELEMENT_ID::FIRE:
  400. $icon .= "fire";
  401. break;
  402. case ELEMENT_ID::LIGHT:
  403. $icon .= "light";
  404. break;
  405. case ELEMENT_ID::DARK:
  406. $icon .= "dark";
  407. break;
  408. }
  409. $icon .= ".png";
  410. }
  411. $html .= "<img class='artifact_base' src='" . $background . "'/>\n";
  412. $html .= "<img class='artifact_icon' src='" . $icon . "'/>\n";
  413. $html .= "<span class='artifact_stars'>\n";
  414. $html .= "</span>\n";
  415. $html .= "<span class='artifact_level'>\n";
  416. $html .= $artifact->level . "\n";
  417. $html .= "</span>\n";
  418. $html .= "</div>\n";
  419. if ($unit instanceof Unit){
  420. $html .= "<div class='assigned'>\n";
  421. $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
  422. $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
  423. $html .= "</a>\n";
  424. $html .= "</div>\n";
  425. }
  426. return $html;
  427. }
  428. /**
  429. * Generates a artifact table.
  430. *
  431. * @param Artifact artifact Entity to get the info from.
  432. * @param Unit unit Optional. The unit the artifact is assigned to.
  433. * @return string HTML content for a artifact table. Empty on error.
  434. */
  435. public static function artifact_table($artifact, $unit = null) {
  436. if (!($artifact instanceof Artifact)){
  437. return "";
  438. }
  439. $html = "";
  440. $html .= "<table class='artifact' id='artifact-" . $artifact->id . "'>\n";
  441. $html .= "<tr>\n";
  442. $html .= "<td class='icon'>\n";
  443. $html .= HTML::artifact_panel($artifact, $unit) . "\n";
  444. $html .= "</td>\n";
  445. $html .= "<td class='effects'>\n";
  446. $html .= "<table>\n";
  447. // Main stat
  448. $html .= "<tr class='effect main_stat'>\n";
  449. $html .= "<td class='effect'>\n";
  450. $stat_name = $artifact->main_stat_name;
  451. $stat_value = "+ " . $artifact->main_stat_value;
  452. $html .= $stat_name . "\n";
  453. $html .= $stat_value . "\n";
  454. $html .= "</td>\n";
  455. $html .= "</tr>\n";
  456. $effects = array($artifact->effect_1_description, $artifact->effect_2_description, $artifact->effect_3_description, $artifact->effect_4_description);
  457. for ($i = 0; $i < 4; $i ++){
  458. $html .= "<tr class='effect'>\n";
  459. $html .= "<td class='effect'>\n";
  460. $html .= $effects[$i];
  461. $html .= "</td>\n";
  462. $html .= "</tr>\n";
  463. }
  464. $html .= "</table>\n";
  465. $html .= "</td>\n";
  466. // Details
  467. /* TODO: Only quaity data, and for that the icon is enough
  468. $html .= "<td class='details'>\n";
  469. $html .= "<table class='table_details'>\n";
  470. $html .= "<tr>\n";
  471. $html .= "<td class='title'>\n";
  472. $html .= "Quality:\n";
  473. $html .= "</td>\n";
  474. $html .= "<td class='value'>\n";
  475. $html .= "<span class='quality quality_" . strtolower($artifact->quality_name) . "'>\n";
  476. $html .= $artifact->quality_name . "\n";
  477. $html .= "</span>\n";
  478. $html .= "</td>\n";
  479. $html .= "</tr>\n";
  480. $html .= "<tr>\n";
  481. $html .= "<td class='title'>\n";
  482. $html .= "Original q.:\n";
  483. $html .= "</td>\n";
  484. $html .= "<td class='value'>\n";
  485. $html .= "<span class='quality quality_" . strtolower($artifact->original_quality_name) . "'>\n";
  486. $html .= $artifact->original_quality_name . "\n";
  487. $html .= "</span>\n";
  488. $html .= "</td>\n";
  489. $html .= "</tr>\n";
  490. $html .= "<tr>\n";
  491. $html .= "<td class='title'>\n";
  492. // TODO: No data on value yet
  493. $html .= ""; //"Value:\n";
  494. $html .= "</td>\n";
  495. $html .= "<td class='value'>\n";
  496. // TODO: No data on value yet
  497. $html .= ""; //number_format($artifact->value, 0, ".", ",") . "\n";
  498. $html .= "</td>\n";
  499. $html .= "</tr>\n";
  500. $html .= "<tr>\n";
  501. $html .= "<td class='title'>\n";
  502. // TODO: No data on efficiencies yet
  503. $html .= ""; //"Efficiency:\n";
  504. $html .= "</td>\n";
  505. $html .= "<td class='value'>\n";
  506. // TODO: No data on efficiencies yet
  507. $html .= ""; //number_format($artifact->efficiency, 2, ".", ",") . "%\n";
  508. $html .= "</td>\n";
  509. $html .= "</tr>\n";
  510. $html .= "<tr>\n";
  511. $html .= "<td class='title'>\n";
  512. // TODO: No data on efficiencies yet
  513. $html .= ""; //"Max. eff.:\n";
  514. $html .= "</td>\n";
  515. $html .= "<td class='value'>\n";
  516. // TODO: No data on efficiencies yet
  517. $html .= ""; //number_format($artifact->max_efficiency, 2, ".", ",") . "%\n";
  518. $html .= "</td>\n";
  519. $html .= "</tr>\n";
  520. $html .= "<tr>\n";
  521. $html .= "<td class='title'>\n";
  522. // TODO: No data on efficiencies yet
  523. $html .= ""; //"Reached. eff.:\n";
  524. $html .= "</td>\n";
  525. $html .= "<td class='value'>\n";
  526. // TODO: No data on efficiencies yet
  527. $html .= ""; //number_format($artifact->efficiency * 100 / $artifact->max_efficiency, 2, ".", ",") . "%\n";
  528. $html .= "</td>\n";
  529. $html .= "</tr>\n";
  530. $html .= "</table>\n";
  531. */
  532. $html .= "</td>\n";
  533. $html .= "</tr>\n";
  534. $html .= "</table>\n";
  535. return $html;
  536. }
  537. /**
  538. * Generates a grindstone or gem panel.
  539. *
  540. * @param Rune_Craft craft Entity to get the info from.
  541. * @return string HTML content for a rune panel. Empty on error.
  542. */
  543. public static function craft_panel($craft) {
  544. if (!($craft instanceof Rune_Craft)){
  545. return "";
  546. }
  547. $html = "";
  548. if ($craft->gem == 1){
  549. if ($craft->inmemorial == 1){
  550. $base = URL::IMG["GRIND"] . "gem_inmemorial.png";
  551. }
  552. else{
  553. $base = URL::IMG["GRIND"] . "gem.png";
  554. }
  555. }
  556. else{
  557. if ($craft->inmemorial == 1){
  558. $base = URL::IMG["GRIND"] . "grind_inmemorial.png";
  559. }
  560. else{
  561. $base = URL::IMG["GRIND"] . "grind.png";
  562. }
  563. }
  564. if ($craft->inmemorial == 0 && isset($craft->rune)){
  565. $icon = "<img class='craft_icon' src='" . $craft->rune->get_image() . "'/>\n";
  566. }
  567. else{
  568. $icon = "";
  569. }
  570. if (in_array($craft->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  571. $stat_name = str_replace("%", "", $craft->stat_name);
  572. $stat_value = "+ " . $craft->min . "~" . $craft->max . "%";
  573. }
  574. else{
  575. $stat_name = $craft->stat_name;
  576. $stat_value = "+ " . $craft->min . "~" . $craft->max;
  577. }
  578. $html .= "<div class='craft_panel craft_quality_" . strtolower($craft->quality_name) . " rune_ancient_" . $craft->ancient . "'>\n";
  579. $html .= "<img class='craft_base' src='" . $base . "'/>\n";
  580. $html .= $icon;
  581. $html .= "<span class='craft_stat'>\n";
  582. $html .= "<span class='craft_stat_name'>" . $stat_name . "</span>\n";
  583. $html .= "<span class='craft_stat_value'>" . $stat_value . "</span>\n";
  584. $html .= "</span>\n";
  585. $html .= "<span class='craft_amount'>\n";
  586. $html .= "x" . $craft->amount . "\n";
  587. $html .= "</span>\n";
  588. $html .= "</div>\n";
  589. return $html;
  590. }
  591. /**
  592. * Generates a building panel.
  593. *
  594. * @param Building|Decoration|K_Building|K_Decoration $building Entity to get the info from.
  595. * @return string HTML content for a building panel. Empty on error.
  596. */
  597. public static function building_panel($building) {
  598. if ($building instanceof Building){
  599. $level = false;
  600. $title = $building->building->name;
  601. $description = $building->building->description;
  602. $img = $building->building->get_image();
  603. }
  604. elseif ($building instanceof K_Building){
  605. $level = false;
  606. $title = $building->name;
  607. $description = $building->building->description;
  608. $img = $building->get_image();
  609. }
  610. elseif ($building instanceof Decoration){
  611. $level = $building->level;
  612. $title = $building->decoration->name;
  613. $description = $building->decoration->description;
  614. $img = $building->decoration->get_image();
  615. }
  616. elseif ($building instanceof K_Decoration){
  617. $level = false;
  618. $title = $building->name;
  619. $description = $building->building->description;
  620. $img = $building->get_image();
  621. }
  622. else{
  623. return "";
  624. }
  625. if (strlen($description) > 0){
  626. $title .= ": " . $description;
  627. }
  628. $html = "";
  629. $html = "<div class='building_panel'>\n";
  630. $html .= "<img title='" . $title . "' class='building' src='" . $img . "'/>\n";
  631. if ($level){
  632. $html .= "<span class='level'>\n";
  633. $html .= $level . "\n";
  634. $html .= "</span>\n";
  635. }
  636. $html .= "</div>\n";
  637. return $html;
  638. }
  639. /**
  640. * Generates a item panel.
  641. *
  642. * @param Inventory $item Entity to get the info from.
  643. * @return string HTML content for a building panel. Empty on error.
  644. */
  645. public static function item_panel($item) {
  646. if (!($item instanceof Inventory)){
  647. return "";
  648. }
  649. $html = "";
  650. $html = "<div class='item_panel'>\n";
  651. $html .= "<img title='" . $item->name . "' class='item' src='" . $item->get_image() . "'/>\n";
  652. $html .= "<span class='amount'>\n";
  653. $html .= $item->amount . "\n";
  654. $html .= "</span>\n";
  655. $html .= "</div>\n";
  656. return $html;
  657. }
  658. }
  659. ?>