html.php 15 KB

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