K_Area.php 11 KB

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