html.php 15 KB

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