K_Area.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * An area.
  5. *
  6. * Represents an object from the table 'k_area'.
  7. */
  8. class K_Area extends Entity{
  9. /**
  10. * Area identifier (it may not be unique!).
  11. */
  12. public $id;
  13. /**
  14. * Area type.
  15. */
  16. public $type;
  17. /**
  18. * Area name.
  19. */
  20. public $name;
  21. /**
  22. * Constructor.
  23. *
  24. * Searches the database and retrieves the information about the
  25. * run, populating it and it's items.
  26. *
  27. * @param SQLite3 $db Connection to the database.
  28. * @param int $id Area identifier.
  29. * @param int $type Area type (required).
  30. */
  31. public function __construct($db, $id, $type){
  32. global $path;
  33. global $AREA_TYPE;
  34. parent::__construct($db);
  35. $this->id = $id;
  36. $s = "
  37. SELECT
  38. id,
  39. type,
  40. name
  41. FROM k_area
  42. WHERE id = '$id'
  43. ORDER BY type = '$type' DESC;
  44. ";
  45. $q = $this->db->query($s);
  46. $r = $q->fetchArray(SQLITE3_ASSOC);
  47. if ($r){
  48. $this->type = $r["type"];
  49. $this->name = $r["name"];
  50. }
  51. elseif($this->id > 1000){
  52. $this->type = $AREA_TYPE["CAIROS_DUNGEON"];
  53. $this->name = "Hall of Heroes";
  54. }
  55. }
  56. /**
  57. * Gets the path to the area image. The image must be in the
  58. * img/area/ directory, and its name must be the monster id,
  59. * padded with '0' to 9 digites, and the extension must be '.png'.
  60. *
  61. * @return path to the image, or a path to a fixed unknown image if it
  62. * doesn't exist.
  63. */
  64. public function get_image($stage = null){
  65. global $base_dir;
  66. global $path;
  67. global $AREA_TYPE;
  68. global $DUNGEON;
  69. if ($this->id > 10000 && file_exists($base_dir . "img/area/HOH.png")){
  70. // Hall of Heroes
  71. return $path["img"]["area"] . "HOH.png";
  72. }
  73. elseif (
  74. (
  75. $this->type == $AREA_TYPE["SCENARIO"] ||
  76. $this->type == $AREA_TYPE["RIFT_DUNGEON"] ||
  77. $this->type == $AREA_TYPE["DIMENSIONAL_HOLE"] ||
  78. $this->type == $AREA_TYPE["RIFT_RAID"] ||
  79. $this->type == $AREA_TYPE["ARENA"] ||
  80. $this->type == $AREA_TYPE["GUILD_WAR"] ||
  81. $this->type == $AREA_TYPE["GUILD_SIEGE"] ||
  82. $this->type == $AREA_TYPE["TARTARUS_LABYRINTH"] ||
  83. $this->type == $AREA_TYPE["TRIAL_OF_ASCENSION"] ||
  84. $this->type == $AREA_TYPE["WORLD_BOSS"] ||
  85. $this->type == $AREA_TYPE["DIMENSIONAL_RIFT"]
  86. ) && file_exists($base_dir . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")
  87. ){
  88. return $path["img"]["area"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  89. }
  90. elseif ($this->type == $AREA_TYPE["CAIROS_DUNGEON"] && in_array($this->id, $DUNGEON)){
  91. switch ($this->id){
  92. case $DUNGEON["GIANTS_KEEP"]:
  93. switch ($stage){
  94. case 1:
  95. case 6:
  96. // Light
  97. if (file_exists($base_dir . "img/unit/00060204.png")){
  98. return $path["img"]["unit"] . "00060204.png";
  99. }
  100. break;
  101. break;
  102. case 2:
  103. case 7:
  104. // Dark
  105. if (file_exists($base_dir . "img/unit/00060204.png")){
  106. return $path["img"]["unit"] . "00060204.png";
  107. }
  108. break;
  109. case 3:
  110. case 8:
  111. // Wind
  112. if (file_exists($base_dir . "img/unit/00060203.png")){
  113. return $path["img"]["unit"] . "00060203.png";
  114. }
  115. break;
  116. case 4:
  117. case 9:
  118. // Fire
  119. if (file_exists($base_dir . "img/unit/00060202.png")){
  120. return $path["img"]["unit"] . "00060202.png";
  121. }
  122. break;
  123. case 5:
  124. case 10:
  125. // Water
  126. if (file_exists($base_dir . "img/unit/00060201.png")){
  127. return $path["img"]["unit"] . "00060201.png";
  128. }
  129. break;
  130. }
  131. break;
  132. case $DUNGEON["DRAGONS_LAIR"]:
  133. switch ($stage){
  134. case 1:
  135. case 6:
  136. // Wind
  137. if (file_exists($base_dir . "img/unit/00060303.png")){
  138. return $path["img"]["unit"] . "00060303.png";
  139. }
  140. break;
  141. break;
  142. case 2:
  143. case 7:
  144. // Light
  145. if (file_exists($base_dir . "img/unit/00060304.png")){
  146. return $path["img"]["unit"] . "00060304.png";
  147. }
  148. break;
  149. case 3:
  150. case 8:
  151. // Water
  152. if (file_exists($base_dir . "img/unit/00060301.png")){
  153. return $path["img"]["unit"] . "00060301.png";
  154. }
  155. break;
  156. case 4:
  157. case 9:
  158. // Dark
  159. if (file_exists($base_dir . "img/unit/00060305.png")){
  160. return $path["img"]["unit"] . "00060305.png";
  161. }
  162. break;
  163. case 5:
  164. case 10:
  165. // Fire
  166. if (file_exists($base_dir . "img/unit/00060302.png")){
  167. return $path["img"]["unit"] . "00060302.png";
  168. }
  169. break;
  170. }
  171. break;
  172. case $DUNGEON["NECROPOLIS"]:
  173. switch ($stage){
  174. case 1:
  175. case 6:
  176. // Water
  177. if (file_exists($base_dir . "img/unit/000621301.png")){
  178. return $path["img"]["unit"] . "000621301.png";
  179. }
  180. break;
  181. break;
  182. case 2:
  183. case 7:
  184. // Fire
  185. if (file_exists($base_dir . "img/unit/000621302.png")){
  186. return $path["img"]["unit"] . "000621302.png";
  187. }
  188. break;
  189. case 3:
  190. case 8:
  191. // Wind
  192. if (file_exists($base_dir . "img/unit/000621303.png")){
  193. return $path["img"]["unit"] . "000621303.png";
  194. }
  195. break;
  196. case 4:
  197. case 9:
  198. // Light
  199. if (file_exists($base_dir . "img/unit/000621304.png")){
  200. return $path["img"]["unit"] . "000621304.png";
  201. }
  202. break;
  203. case 5:
  204. case 10:
  205. // Dark
  206. if (file_exists($base_dir . "img/unit/000621305.png")){
  207. return $path["img"]["unit"] . "000621305.png";
  208. }
  209. break;
  210. }
  211. break;
  212. case $DUNGEON["HALL_OF_WATER"]:
  213. if (file_exists($base_dir . "img/unit/00060101.png")){
  214. return $path["img"]["unit"] . "00060101.png";
  215. }
  216. break;
  217. case $DUNGEON["HALL_OF_FIRE"]:
  218. if (file_exists($base_dir . "img/unit/00060102.png")){
  219. return $path["img"]["unit"] . "00060102.png";
  220. }
  221. break;
  222. case $DUNGEON["HALL_OF_WIND"]:
  223. if (file_exists($base_dir . "img/unit/00060103.png")){
  224. return $path["img"]["unit"] . "00060103.png";
  225. }
  226. break;
  227. case $DUNGEON["HALL_OF_LIGHT"]:
  228. if (file_exists($base_dir . "img/unit/00060104.png")){
  229. return $path["img"]["unit"] . "00060104.png";
  230. }
  231. break;
  232. case $DUNGEON["HALL_OF_DARK"]:
  233. if (file_exists($base_dir . "img/unit/00060105.png")){
  234. return $path["img"]["unit"] . "00060105.png";
  235. }
  236. break;
  237. case $DUNGEON["HALL_OF_MAGIC"]:
  238. if (file_exists($base_dir . "img/unit/00062004.png")){
  239. return $path["img"]["unit"] . "00062004.png";
  240. }
  241. break;
  242. default:
  243. if (file_exists($base_dir . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  244. return $path["img"]["area"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  245. }
  246. }
  247. }
  248. return $path["img"]["root"] . "unknown.png";
  249. }
  250. }
  251. ?>