K_Area.php 11 KB

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