html.php 16 KB

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