html.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <?php
  2. /**
  3. * Generates a monster panel.
  4. *
  5. * @param unit Unit/K_Unit Entity to get the info from.
  6. * @return string HTML content for a monster panel. Empty on error.
  7. */
  8. function html_unit_panel($unit) {
  9. global $path;
  10. if ($unit instanceof Unit){
  11. $k = $unit->unit;
  12. $stars = $unit->stars;
  13. $level = true;
  14. $teams = (sizeof($unit->teams) > 0);
  15. $lock = $unit->lock;
  16. $storage = $unit->in_storage;
  17. $maxed = ($unit->level == 40 && $unit->are_skills_maxed());
  18. }
  19. elseif ($unit instanceof K_Unit){
  20. $k = $unit;
  21. $stars = $unit->base_stars;
  22. $level = false;
  23. $teams = 0;
  24. $lock = false;
  25. $storage = false;
  26. $maxed = false;
  27. }
  28. else{
  29. return "";
  30. }
  31. $html = "";
  32. if ($k->awakens_from == "" && $k->awakens_to == ""){
  33. // No to, no from, silver monster.
  34. $star_class ="star_silver";
  35. }
  36. elseif ($k->awakens_from != ""){
  37. // Already awakened
  38. if ($k->base_stars - $k->natural_stars == 1){
  39. // Normal awaken.
  40. $star_class ="star_purple";
  41. }
  42. else{
  43. // Second awaken.
  44. $star_class ="star_red";
  45. }
  46. }
  47. elseif ($k->awakens_to != ""){
  48. // Awakeable.
  49. $star_class ="star_gold";
  50. }
  51. $html .= "<span class='stars'>\n";
  52. for ($i = 0; $i < $stars; $i ++){
  53. $html .= "<img class='star $star_class' src='" . $path["img"]["icon"] . "star.png'/>\n";
  54. }
  55. $html .= "</span>\n";
  56. $html .= "<img title='" . $unit->title . "' class='monster border_" . $k->element_name . "' src='" . $k->get_image() . "'/>\n";
  57. if ($level){
  58. $html .= "<span class='level'>\n";
  59. $html .= $unit->level . "\n";
  60. $html .= "</span>\n";
  61. }
  62. $html .= "<span class='badges'>\n";
  63. if ($maxed){
  64. $html .= "<img title='Maxed unit' src='" . $path["img"]["icon"] . "maxed.png'>";
  65. }
  66. if ($teams > 0){
  67. $title = $teams . " teams";
  68. if ($teams == 1){
  69. $title = "1 team: " . $unit->teams[0]->name;
  70. }
  71. $html .= "<img title='$title' src='" . $path["img"]["icon"] . "team.png'>";
  72. }
  73. if ($lock == 1){
  74. $html .= "<img title='Locked' src='" . $path["img"]["icon"] . "lock.png'>";
  75. }
  76. if ($storage){
  77. $html .= "<img title='In storage' src='" . $path["img"]["icon"] . "storage.png'>";
  78. }
  79. $html .= "</span>\n";
  80. return $html;
  81. }
  82. /**
  83. * Generates a transformed monster panel.
  84. *
  85. * @param unit Unit/K_Unit Entity to get the info from.
  86. * @return string HTML content for a monster panel. Empty on error.
  87. */
  88. function html_unit_transformation_panel($unit) {
  89. global $path;
  90. $html = "";
  91. if ($unit instanceof Unit){
  92. $k = $unit->unit;
  93. }
  94. elseif ($unit instanceof K_Unit){
  95. $k = $unit;
  96. }
  97. else{
  98. return "";
  99. }
  100. if ($k->transformation == null){
  101. return "";
  102. }
  103. $html .= "<div class='monster_transformation_panel'>\n";
  104. $html .= "<img title='" . $unit->title . " (transformed)' class='monster_transformation border_" . $k->element_name . "' src='" . $k->transformation->get_image() . "'/>\n";
  105. $html .= "</div>\n";
  106. return $html;
  107. }
  108. /**
  109. * Generates a rune panel.
  110. *
  111. * @param Rune rune Entity to get the info from.
  112. * @param Unit unit Optional. The unit the rune is assigned to.
  113. * @return string HTML content for a rune panel. Empty on error.
  114. */
  115. function html_rune_panel($rune, $unit = null) {
  116. global $path;
  117. if (!($rune instanceof Rune)){
  118. return "";
  119. }
  120. $html = "";
  121. $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";
  122. $html .= "<img class='rune_base' src='" . $path["img"]["rune"] . "base.png'/>\n";
  123. $html .= "<img class='rune_icon' src='" . $rune->type->get_image() . "'/>\n";
  124. $html .= "<span class='rune_stars'>\n";
  125. for ($i = 0; $i < $rune->stars; $i ++){
  126. $html .= "<img class='star' src='" . $path["img"]["icon"] . "star.png'/>\n";
  127. }
  128. $html .= "</span>\n";
  129. $html .= "<span class='rune_level'>\n";
  130. $html .= $rune->level . "\n";
  131. $html .= "</span>\n";
  132. $html .= "</div>\n";
  133. if ($unit instanceof Unit){
  134. $html .= "<div class='assigned'>\n";
  135. $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
  136. $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
  137. $html .= "</a>\n";
  138. $html .= "</div>\n";
  139. }
  140. return $html;
  141. }
  142. /**
  143. * Generates a rune table.
  144. *
  145. * @param Rune rune Entity to get the info from.
  146. * @param Unit unit Optional. The unit the rune is assigned to.
  147. * @return string HTML content for a rune table. Empty on error.
  148. */
  149. function html_rune_table($rune, $unit = null) {
  150. global $path;
  151. if (!($rune instanceof Rune)){
  152. return "";
  153. }
  154. $html = "";
  155. $html .= "<table class='rune'>\n";
  156. $html .= "<tr>\n";
  157. $html .= "<td class='icon'>\n";
  158. $html .= html_rune_panel($rune, $unit) . "\n";
  159. $html .= "</td>\n";
  160. $html .= "<td class='stats'>\n";
  161. $html .= "<table>\n";
  162. // Main stat
  163. $html .= "<tr class='main_stat'>\n";
  164. $html .= "<td class='stat'>\n";
  165. if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  166. $stat_name = str_replace("%", "", $rune->main_stat_name);
  167. $stat_value = "+ " . $rune->main_stat_value . "%";
  168. }
  169. else{
  170. $stat_name = $rune->main_stat_name;
  171. $stat_value = "+ " . $rune->main_stat_value;
  172. }
  173. $html .= $stat_name . "\n";
  174. $html .= "</td>\n";
  175. $html .= "<td class='value'>\n";
  176. $html .= $stat_value . "\n";
  177. $html .= "<td>\n";
  178. $html .= "</tr>\n";
  179. // Innate stat
  180. $html .= "<tr class='innate_stat'>\n";
  181. $html .= "<td class='stat'>\n";
  182. if (strlen($rune->innate_stat) == 0){
  183. $stat_name = "&nbsp;";
  184. $stat_value = "";
  185. }
  186. elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  187. $stat_name = str_replace("%", "", $rune->innate_stat_name);
  188. $stat_value = "+ " . $rune->innate_stat_value . "%";
  189. }
  190. else{
  191. $stat_name = $rune->innate_stat_name;
  192. $stat_value = "+ " . $rune->innate_stat_value;
  193. }
  194. $html .= $stat_name . "\n";
  195. $html .= "</td>\n";
  196. $html .= "<td class='value'>\n";
  197. $html .= $stat_value . "\n";
  198. $html .= "<td>\n";
  199. $html .= "</tr>\n";
  200. $substats = array($rune->substat_1, $rune->substat_2, $rune->substat_3, $rune->substat_4);
  201. $substats_name = array($rune->substat_1_name, $rune->substat_2_name, $rune->substat_3_name, $rune->substat_4_name);
  202. $substats_value = array($rune->substat_1_value, $rune->substat_2_value, $rune->substat_3_value, $rune->substat_4_value);
  203. $substats_grind = array($rune->substat_1_grind, $rune->substat_2_grind, $rune->substat_3_grind, $rune->substat_4_grind);
  204. $substats_enchant = array($rune->substat_1_enchant, $rune->substat_2_enchant, $rune->substat_3_enchant, $rune->substat_4_enchant);
  205. for ($i = 0; $i < 4; $i ++){
  206. if (strlen($substats_name[$i]) == 0){
  207. $stat_name = "&nbsp;";
  208. $stat_value = "";
  209. }
  210. elseif (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  211. $stat_name = str_replace("%", "", $substats_name[$i]);
  212. $stat_value = "+ " . $substats_value[$i] . "%";
  213. }
  214. else{
  215. $stat_name = $substats_name[$i];
  216. $stat_value = "+ " . $substats_value[$i];
  217. }
  218. $grind = "";
  219. if ($substats_grind[$i] > 0){
  220. $grind = "+" . $substats_grind[$i];
  221. if (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  222. $grind = $grind . "%";
  223. }
  224. }
  225. $html .= "<tr class=substat>\n";
  226. $html .= "<td class='stat'>\n";
  227. $html .= $stat_name . "\n";
  228. $html .= "</td>\n";
  229. $html .= "<td class='value'>\n";
  230. $html .= $stat_value . "\n";
  231. $html .= "<span class='grind grind_$grind'>\n";
  232. $html .= $grind . "\n";
  233. $html .= "</span>\n";
  234. if ($substats_enchant[$i] == 1){
  235. $html .= "<img title='Enchanted' src='" . $path["img"]["rune"] . "enchanted.png'/>\n";
  236. }
  237. $html .= "</td>\n";
  238. $html .= "</tr>\n";
  239. }
  240. $html .= "</table>\n";
  241. $html .= "</td>\n";
  242. // Details
  243. $html .= "<td class='details'>\n";
  244. $html .= "<table class='table_details'>\n";
  245. $html .= "<tr>\n";
  246. $html .= "<td class='title'>\n";
  247. $html .= "Quality:\n";
  248. $html .= "</td>\n";
  249. $html .= "<td class='value'>\n";
  250. $html .= "<span class='quality quality_" . strtolower($rune->quality_name) . "'>\n";
  251. $html .= $rune->quality_name . "\n";
  252. $html .= "</span>\n";
  253. $html .= "</td>\n";
  254. $html .= "</tr>\n";
  255. $html .= "<tr>\n";
  256. $html .= "<td class='title'>\n";
  257. $html .= "Origina q.:\n";
  258. $html .= "</td>\n";
  259. $html .= "<td class='value'>\n";
  260. $html .= "<span class='quality quality_" . strtolower($rune->original_quality_name) . "'>\n";
  261. $html .= $rune->original_quality_name . "\n";
  262. $html .= "</span>\n";
  263. $html .= "</td>\n";
  264. $html .= "</tr>\n";
  265. $html .= "<tr>\n";
  266. $html .= "<td class='title'>\n";
  267. $html .= "Value:\n";
  268. $html .= "</td>\n";
  269. $html .= "<td class='value'>\n";
  270. $html .= number_format($rune->value, 0, ".", ",") . "\n";
  271. $html .= "</td>\n";
  272. $html .= "</tr>\n";
  273. $html .= "<tr>\n";
  274. $html .= "<td class='title'>\n";
  275. $html .= "Efficiency:\n";
  276. $html .= "</td>\n";
  277. $html .= "<td class='value'>\n";
  278. $html .= number_format($rune->efficiency, 2, ".", ",") . "%\n";
  279. $html .= "</td>\n";
  280. $html .= "</tr>\n";
  281. $html .= "<tr>\n";
  282. $html .= "<td class='title'>\n";
  283. $html .= "Max. eff.:\n";
  284. $html .= "</td>\n";
  285. $html .= "<td class='value'>\n";
  286. $html .= number_format($rune->max_efficiency, 2, ".", ",") . "%\n";
  287. $html .= "</td>\n";
  288. $html .= "</tr>\n";
  289. $html .= "<tr>\n";
  290. $html .= "<td class='title'>\n";
  291. $html .= "Reached. eff.:\n";
  292. $html .= "</td>\n";
  293. $html .= "<td class='value'>\n";
  294. $html .= number_format($rune->efficiency * 100 / $rune->max_efficiency, 2, ".", ",") . "%\n";
  295. $html .= "</td>\n";
  296. $html .= "</tr>\n";
  297. $html .= "</table>\n";
  298. $html .= "</td>\n";
  299. $html .= "</tr>\n";
  300. $html .= "</table>\n";
  301. return $html;
  302. }
  303. /**
  304. * Generates a grindstone or gem panel.
  305. *
  306. * @param Rune_Craft craft Entity to get the info from.
  307. * @return string HTML content for a rune panel. Empty on error.
  308. */
  309. function html_craft_panel($craft) {
  310. global $path;
  311. if (!($craft instanceof Rune_Craft)){
  312. return "";
  313. }
  314. $html = "";
  315. if ($craft->gem == 1){
  316. if ($craft->inmemorial == 1){
  317. $base = $path["img"]["grind"] . "gem_inmemorial.png";
  318. }
  319. else{
  320. $base = $path["img"]["grind"] . "gem.png";
  321. }
  322. }
  323. else{
  324. if ($craft->inmemorial == 1){
  325. $base = $path["img"]["grind"] . "grind_inmemorial.png";
  326. }
  327. else{
  328. $base = $path["img"]["grind"] . "grind.png";
  329. }
  330. }
  331. if ($craft->inmemorial == 0 && isset($craft->rune)){
  332. $icon = "<img class='craft_icon' src='" . $craft->rune->get_image() . "'/>\n";
  333. }
  334. else{
  335. $icon = "";
  336. }
  337. if (in_array($craft->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
  338. $stat_name = str_replace("%", "", $craft->stat_name);
  339. $stat_value = "+ " . $craft->min . "~" . $craft->max . "%";
  340. }
  341. else{
  342. $stat_name = $craft->stat_name;
  343. $stat_value = "+ " . $craft->min . "~" . $craft->max;
  344. }
  345. $html .= "<div class='craft_panel craft_quality_" . strtolower($craft->quality_name) . " rune_ancient_" . $craft->ancient . "'>\n";
  346. $html .= "<img class='craft_base' src='" . $base . "'/>\n";
  347. $html .= $icon;
  348. $html .= "<span class='craft_stat'>\n";
  349. $html .= "<span class='craft_stat_name'>" . $stat_name . "</span>\n";
  350. $html .= "<span class='craft_stat_value'>" . $stat_value . "</span>\n";
  351. $html .= "</span>\n";
  352. $html .= "</div>\n";
  353. return $html;
  354. }
  355. /**
  356. * Generates a building panel.
  357. *
  358. * @param unit Building/Decoration/K_Building/K_Decoration Entity to get the info from.
  359. * @return string HTML content for a building panel. Empty on error.
  360. */
  361. function html_building_panel($building) {
  362. global $path;
  363. if ($building instanceof Building){
  364. $level = false;
  365. $title = $building->building->name;
  366. $description = $building->building->description;
  367. $img = $building->building->get_image();
  368. }
  369. elseif ($building instanceof K_Building){
  370. $level = false;
  371. $title = $building->name;
  372. $description = $building->building->description;
  373. $img = $building->get_image();
  374. }
  375. elseif ($building instanceof Decoration){
  376. $level = $building->level;
  377. $title = $building->decoration->name;
  378. $description = $building->decoration->description;
  379. $img = $building->decoration->get_image();
  380. }
  381. elseif ($building instanceof K_Decoration){
  382. $level = false;
  383. $title = $building->name;
  384. $description = $building->building->description;
  385. $img = $building->get_image();
  386. }
  387. else{
  388. return "";
  389. }
  390. if (strlen($description) > 0){
  391. $title .= ": " . $description;
  392. }
  393. $html = "";
  394. $html = "<div class='building_panel'>\n";
  395. $html .= "<img title='" . $title . "' class='building' src='" . $img . "'/>\n";
  396. if ($level){
  397. $html .= "<span class='level'>\n";
  398. $html .= $level . "\n";
  399. $html .= "</span>\n";
  400. }
  401. $html .= "</div>\n";
  402. return $html;
  403. }
  404. /**
  405. * Generates a item panel.
  406. *
  407. * @param item Inventory Entity to get the info from.
  408. * @return string HTML content for a building panel. Empty on error.
  409. */
  410. function html_item_panel($item) {
  411. global $path;
  412. global $INVENTORY_TYPE;
  413. if (!($item instanceof Inventory)){
  414. return "";
  415. }
  416. $html = "";
  417. $html = "<div class='item_panel'>\n";
  418. $html .= "<img title='" . $item->name . "' class='item' src='" . $item->get_image() . "'/>\n";
  419. $html .= "<span class='amount'>\n";
  420. $html .= $item->amount . "\n";
  421. $html .= "</span>\n";
  422. $html .= "</div>\n";
  423. return $html;
  424. }
  425. ?>