HTML_Helper.php 28 KB

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