html.php 14 KB

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