html.php 14 KB

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