K_Area.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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. $this->type = $type;
  47. $s = "
  48. SELECT
  49. id,
  50. type,
  51. name
  52. FROM k_area
  53. WHERE
  54. id = '$id' AND
  55. type = '$type'
  56. ORDER BY type = '$type' DESC;
  57. ";
  58. $q = $this->db->query($s);
  59. $r = $q->fetchArray(SQLITE3_ASSOC);
  60. if ($r){
  61. $this->name = HTML::e($r["name"]);
  62. }
  63. elseif($this->id > 1000){
  64. $this->type = AREA_TYPE_ID::CAIROS_DUNGEON;
  65. $this->name = "Hall of Heroes";
  66. }
  67. }
  68. /**
  69. * Gets the path to the area image. The image must be in the
  70. * img/area/ directory, and its name must be the area type id,
  71. * padded with '0' to 9 digites, and the extension must be '.png'.
  72. *
  73. * @param string $stage Stage number, for a better image in Cairos.
  74. * @return string Image URL, or a fixed unknown image.
  75. */
  76. public function get_image($stage = null){
  77. if ($this->id > 10000 && file_exists(PATH::BASE . "img/area/HOH.png")){
  78. // Hall of Heroes
  79. return URL::IMG["AREA"] . "HOH.png";
  80. }
  81. elseif (
  82. (
  83. $this->type == AREA_TYPE_ID::SCENARIO ||
  84. //$this->type == AREA_TYPE_ID::RIFT_DUNGEON ||
  85. //$this->type == AREA_TYPE_ID::DIMENSIONAL_HOLE ||
  86. //$this->type == AREA_TYPE_ID::RIFT_RAID ||
  87. $this->type == AREA_TYPE_ID::ARENA ||
  88. $this->type == AREA_TYPE_ID::GUILD_WAR ||
  89. $this->type == AREA_TYPE_ID::GUILD_SIEGE ||
  90. //$this->type == AREA_TYPE_ID::TARTARUS_LABYRINTH ||
  91. //$this->type == AREA_TYPE_ID::TRIAL_OF_ASCENSION ||
  92. $this->type == AREA_TYPE_ID::WORLD_BOSS ||
  93. $this->type == AREA_TYPE_ID::DIMENSIONAL_RIFT
  94. ) && file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")
  95. ){
  96. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  97. }
  98. elseif ($this->type == AREA_TYPE_ID::CAIROS_DUNGEON && APPLICATION::valid_id("DUNGEON_ID", $this->id)){
  99. switch ($this->id){
  100. case DUNGEON_ID::GIANTS_KEEP:
  101. switch ($stage){
  102. case 1:
  103. case 6:
  104. // Light
  105. if (file_exists(PATH::BASE . "img/unit/00060204.png")){
  106. return URL::IMG["UNIT"] . "00060204.png";
  107. }
  108. break;
  109. break;
  110. case 2:
  111. case 7:
  112. // Dark
  113. if (file_exists(PATH::BASE . "img/unit/00060204.png")){
  114. return URL::IMG["UNIT"] . "00060204.png";
  115. }
  116. break;
  117. case 3:
  118. case 8:
  119. // Wind
  120. if (file_exists(PATH::BASE . "img/unit/00060203.png")){
  121. return URL::IMG["UNIT"] . "00060203.png";
  122. }
  123. break;
  124. case 4:
  125. case 9:
  126. // Fire
  127. if (file_exists(PATH::BASE . "img/unit/00060202.png")){
  128. return URL::IMG["UNIT"] . "00060202.png";
  129. }
  130. break;
  131. case 5:
  132. case 10:
  133. // Water
  134. if (file_exists(PATH::BASE . "img/unit/00060201.png")){
  135. return URL::IMG["UNIT"] . "00060201.png";
  136. }
  137. break;
  138. }
  139. break;
  140. case DUNGEON_ID::DRAGONS_LAIR:
  141. switch ($stage){
  142. case 1:
  143. case 6:
  144. // Wind
  145. if (file_exists(PATH::BASE . "img/unit/00060303.png")){
  146. return URL::IMG["UNIT"] . "00060303.png";
  147. }
  148. break;
  149. break;
  150. case 2:
  151. case 7:
  152. // Light
  153. if (file_exists(PATH::BASE . "img/unit/00060304.png")){
  154. return URL::IMG["UNIT"] . "00060304.png";
  155. }
  156. break;
  157. case 3:
  158. case 8:
  159. // Water
  160. if (file_exists(PATH::BASE . "img/unit/00060301.png")){
  161. return URL::IMG["UNIT"] . "00060301.png";
  162. }
  163. break;
  164. case 4:
  165. case 9:
  166. // Dark
  167. if (file_exists(PATH::BASE . "img/unit/00060305.png")){
  168. return URL::IMG["UNIT"] . "00060305.png";
  169. }
  170. break;
  171. case 5:
  172. case 10:
  173. // Fire
  174. if (file_exists(PATH::BASE . "img/unit/00060302.png")){
  175. return URL::IMG["UNIT"] . "00060302.png";
  176. }
  177. break;
  178. }
  179. break;
  180. case DUNGEON_ID::NECROPOLIS:
  181. switch ($stage){
  182. case 1:
  183. case 6:
  184. // Water
  185. if (file_exists(PATH::BASE . "img/unit/00062101.png")){
  186. return URL::IMG["UNIT"] . "00062101.png";
  187. }
  188. break;
  189. break;
  190. case 2:
  191. case 7:
  192. // Fire
  193. if (file_exists(PATH::BASE . "img/unit/00062102.png")){
  194. return URL::IMG["UNIT"] . "00062102.png";
  195. }
  196. break;
  197. case 3:
  198. case 8:
  199. // Wind
  200. if (file_exists(PATH::BASE . "img/unit/00062103.png")){
  201. return URL::IMG["UNIT"] . "00062103.png";
  202. }
  203. break;
  204. case 4:
  205. case 9:
  206. // Light
  207. if (file_exists(PATH::BASE . "img/unit/00062104.png")){
  208. return URL::IMG["UNIT"] . "00062104.png";
  209. }
  210. break;
  211. case 5:
  212. case 10:
  213. // Dark
  214. if (file_exists(PATH::BASE . "img/unit/00062105.png")){
  215. return URL::IMG["UNIT"] . "00062105.png";
  216. }
  217. break;
  218. }
  219. break;
  220. case DUNGEON_ID::HALL_OF_WATER:
  221. if (file_exists(PATH::BASE . "img/unit/00060101.png")){
  222. return URL::IMG["UNIT"] . "00060101.png";
  223. }
  224. break;
  225. case DUNGEON_ID::HALL_OF_FIRE:
  226. if (file_exists(PATH::BASE . "img/unit/00060102.png")){
  227. return URL::IMG["UNIT"] . "00060102.png";
  228. }
  229. break;
  230. case DUNGEON_ID::HALL_OF_WIND:
  231. if (file_exists(PATH::BASE . "img/unit/00060103.png")){
  232. return URL::IMG["UNIT"] . "00060103.png";
  233. }
  234. break;
  235. case DUNGEON_ID::HALL_OF_LIGHT:
  236. if (file_exists(PATH::BASE . "img/unit/00060104.png")){
  237. return URL::IMG["UNIT"] . "00060104.png";
  238. }
  239. break;
  240. case DUNGEON_ID::HALL_OF_DARK:
  241. if (file_exists(PATH::BASE . "img/unit/00060105.png")){
  242. return $PATH["IMG"]["UNIT"] . "00060105.png";
  243. }
  244. break;
  245. case DUNGEON_ID::HALL_OF_MAGIC:
  246. if (file_exists(PATH::BASE . "img/unit/00062004.png")){
  247. return URL::IMG["UNIT"] . "00062004.png";
  248. }
  249. break;
  250. default:
  251. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  252. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  253. }
  254. }
  255. }
  256. elseif ($this->type == AREA_TYPE_ID::RIFT_DUNGEON && APPLICATION::valid_id("ELEMENTAL_RIFT_DUNGEON_ID", $this->id)){
  257. switch ($this->id){
  258. case ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST:
  259. if (file_exists(PATH::BASE . "img/unit/00043001.png")){
  260. return URL::IMG["UNIT"] . "00043001.png";
  261. }
  262. break;
  263. case ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST:
  264. if (file_exists(PATH::BASE . "img/unit/00043002.png")){
  265. return URL::IMG["UNIT"] . "00043002.png";
  266. }
  267. break;
  268. case ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST:
  269. if (file_exists(PATH::BASE . "img/unit/00043003.png")){
  270. return URL::IMG["UNIT"] . "00043003.png";
  271. }
  272. break;
  273. case ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST:
  274. if (file_exists(PATH::BASE . "img/unit/00043004.png")){
  275. return URL::IMG["UNIT"] . "00043004.png";
  276. }
  277. break;
  278. case ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST:
  279. if (file_exists(PATH::BASE . "img/unit/00043005.png")){
  280. return URL::IMG["UNIT"] . "00043005.png";
  281. }
  282. break;
  283. default:
  284. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  285. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  286. }
  287. break;
  288. }
  289. }
  290. elseif ($this->type == AREA_TYPE_ID::RIFT_RAID){
  291. if (file_exists(PATH::BASE . "img/unit/00044007.png")){
  292. return URL::IMG["UNIT"] . "00044007.png";
  293. }
  294. }
  295. elseif ($this->type == AREA_TYPE_ID::DIMENSIONAL_HOLE){
  296. switch ($this->id){
  297. case DUNGEON_ID::FOREST_OF_ROARING_BEASTS:
  298. if (file_exists(PATH::BASE . "img/unit/00047002.png")){
  299. return URL::IMG["UNIT"] . "00047002.png";
  300. }
  301. break;
  302. case DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES:
  303. if (file_exists(PATH::BASE . "img/unit/00047001.png")){
  304. return URL::IMG["UNIT"] . "00047001.png";
  305. }
  306. break;
  307. case DUNGEON_ID::CLIFF_OF_TOUGH_BEASTS_MEN:
  308. if (file_exists(PATH::BASE . "img/unit/00047002.png")){
  309. return URL::IMG["UNIT"] . "00047003.png";
  310. }
  311. break;
  312. case DUNGEON_ID::KARZHAN_REMAINS_WARBEAR:
  313. switch ($stage){
  314. case 1:
  315. if (file_exists(PATH::BASE . "img/unit/00010734.png")){
  316. return URL::IMG["UNIT"] . "00010734.png";
  317. }
  318. break;
  319. case 2:
  320. if (file_exists(PATH::BASE . "img/unit/00010733.png")){
  321. return URL::IMG["UNIT"] . "00010733.png";
  322. }
  323. break;
  324. case 3:
  325. if (file_exists(PATH::BASE . "img/unit/00010731.png")){
  326. return URL::IMG["UNIT"] . "00010731.png";
  327. }
  328. break;
  329. case 4:
  330. if (file_exists(PATH::BASE . "img/unit/00010735.png")){
  331. return URL::IMG["UNIT"] . "00010735.png";
  332. }
  333. break;
  334. case 5:
  335. if (file_exists(PATH::BASE . "img/unit/00010732.png")){
  336. return URL::IMG["UNIT"] . "00010732.png";
  337. }
  338. break;
  339. default:
  340. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  341. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  342. }
  343. break;
  344. }
  345. break;
  346. case DUNGEON_ID::KARZHAN_REMAINS_INUGAMI:
  347. switch ($stage){
  348. case 1:
  349. if (file_exists(PATH::BASE . "img/unit/00011031.png")){
  350. return URL::IMG["UNIT"] . "00011031.png";
  351. }
  352. break;
  353. case 2:
  354. if (file_exists(PATH::BASE . "img/unit/00011033.png")){
  355. return URL::IMG["UNIT"] . "00011033.png";
  356. }
  357. break;
  358. case 3:
  359. if (file_exists(PATH::BASE . "img/unit/00011032.png")){
  360. return URL::IMG["UNIT"] . "00011032.png";
  361. }
  362. break;
  363. case 4:
  364. if (file_exists(PATH::BASE . "img/unit/00011034.png")){
  365. return URL::IMG["UNIT"] . "00011034.png";
  366. }
  367. break;
  368. case 5:
  369. if (file_exists(PATH::BASE . "img/unit/00011035.png")){
  370. return URL::IMG["UNIT"] . "00011035.png";
  371. }
  372. break;
  373. default:
  374. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  375. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  376. }
  377. break;
  378. }
  379. break;
  380. case DUNGEON_ID::ELLUNIA_REMAINS_FAIRY:
  381. switch ($stage){
  382. case 1:
  383. if (file_exists(PATH::BASE . "img/unit/00010132.png")){
  384. return URL::IMG["UNIT"] . "00010132.png";
  385. }
  386. break;
  387. case 2:
  388. if (file_exists(PATH::BASE . "img/unit/00010134.png")){
  389. return URL::IMG["UNIT"] . "00010134.png";
  390. }
  391. break;
  392. case 3:
  393. if (file_exists(PATH::BASE . "img/unit/00010131.png")){
  394. return URL::IMG["UNIT"] . "00010131.png";
  395. }
  396. break;
  397. case 4:
  398. if (file_exists(PATH::BASE . "img/unit/00010133.png")){
  399. return URL::IMG["UNIT"] . "00010133.png";
  400. }
  401. break;
  402. case 5:
  403. if (file_exists(PATH::BASE . "img/unit/00010134.png")){
  404. return URL::IMG["UNIT"] . "00010134.png";
  405. }
  406. break;
  407. default:
  408. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  409. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  410. }
  411. break;
  412. }
  413. break;
  414. case DUNGEON_ID::ELLUNIA_REMAINS_PIXIE:
  415. switch ($stage){
  416. case 1:
  417. if (file_exists(PATH::BASE . "img/unit/00010334.png")){
  418. return URL::IMG["UNIT"] . "00010334.png";
  419. }
  420. break;
  421. case 2:
  422. if (file_exists(PATH::BASE . "img/unit/00010332.png")){
  423. return URL::IMG["UNIT"] . "00010332.png";
  424. }
  425. break;
  426. case 3:
  427. if (file_exists(PATH::BASE . "img/unit/00010335.png")){
  428. return URL::IMG["UNIT"] . "00010335.png";
  429. }
  430. break;
  431. case 4:
  432. if (file_exists(PATH::BASE . "img/unit/00010333.png")){
  433. return URL::IMG["UNIT"] . "00010333.png";
  434. }
  435. break;
  436. case 5:
  437. if (file_exists(PATH::BASE . "img/unit/00010331.png")){
  438. return URL::IMG["UNIT"] . "00010331.png";
  439. }
  440. break;
  441. default:
  442. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  443. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  444. }
  445. break;
  446. }
  447. break;
  448. case DUNGEON_ID::LUMEL_REMAINS_WEREWOLF:
  449. switch ($stage){
  450. case 1:
  451. if (file_exists(PATH::BASE . "img/unit/00014035.png")){
  452. return URL::IMG["UNIT"] . "00014035.png";
  453. }
  454. break;
  455. case 2:
  456. if (file_exists(PATH::BASE . "img/unit/00014033.png")){
  457. return URL::IMG["UNIT"] . "00014033.png";
  458. }
  459. break;
  460. case 3:
  461. if (file_exists(PATH::BASE . "img/unit/00014031.png")){
  462. return URL::IMG["UNIT"] . "00014031.png";
  463. }
  464. break;
  465. case 4:
  466. if (file_exists(PATH::BASE . "img/unit/00014034.png")){
  467. return URL::IMG["UNIT"] . "00014034.png";
  468. }
  469. break;
  470. case 5:
  471. if (file_exists(PATH::BASE . "img/unit/00014032.png")){
  472. return URL::IMG["UNIT"] . "00014032.png";
  473. }
  474. break;
  475. default:
  476. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  477. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  478. }
  479. break;
  480. }
  481. break;
  482. case DUNGEON_ID::LUMEL_REMAINS_MARTIAL_CAT:
  483. switch ($stage){
  484. case 1:
  485. if (file_exists(PATH::BASE . "img/unit/00015032.png")){
  486. return URL::IMG["UNIT"] . "00015032.png";
  487. }
  488. break;
  489. case 2:
  490. if (file_exists(PATH::BASE . "img/unit/00015034.png")){
  491. return URL::IMG["UNIT"] . "00015034.png";
  492. }
  493. break;
  494. case 3:
  495. if (file_exists(PATH::BASE . "img/unit/00015031.png")){
  496. return URL::IMG["UNIT"] . "00015031.png";
  497. }
  498. break;
  499. case 4:
  500. if (file_exists(PATH::BASE . "img/unit/00015035.png")){
  501. return URL::IMG["UNIT"] . "00015035.png";
  502. }
  503. break;
  504. case 5:
  505. if (file_exists(PATH::BASE . "img/unit/00015033.png")){
  506. return URL::IMG["UNIT"] . "00015033.png";
  507. }
  508. break;
  509. default:
  510. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  511. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  512. }
  513. break;
  514. }
  515. break;
  516. default:
  517. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  518. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  519. }
  520. break;
  521. }
  522. }
  523. elseif ($this->type == AREA_TYPE_ID::TARTARUS_LABYRINTH){
  524. switch ($stage){
  525. case LABYRINTH_STAGES_ID::TARTARUS:
  526. if (file_exists(PATH::BASE . "img/unit/00046001.png")){
  527. return URL::IMG["UNIT"] . "00046001.png";
  528. }
  529. break;
  530. case LABYRINTH_STAGES_ID::LEOS:
  531. if (file_exists(PATH::BASE . "img/unit/00046101.png")){
  532. return URL::IMG["UNIT"] . "00046101.png";
  533. }
  534. break;
  535. case LABYRINTH_STAGES_ID::KOTTOS:
  536. if (file_exists(PATH::BASE . "img/unit/00046102.png")){
  537. return URL::IMG["UNIT"] . "00046102.png";
  538. }
  539. break;
  540. case LABYRINTH_STAGES_ID::AQUILES:
  541. if (file_exists(PATH::BASE . "img/unit/00046103.png")){
  542. return URL::IMG["UNIT"] . "00046103.png";
  543. }
  544. break;
  545. default:
  546. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  547. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  548. }
  549. else{
  550. return URL::IMG["UNKNOWN"];
  551. }
  552. }
  553. }
  554. elseif ($this->type == AREA_TYPE_ID::TRIAL_OF_ASCENSION){
  555. if (file_exists(PATH::BASE . "img/area/TRIAL_OF_ASCENSION.png")){
  556. return URL::IMG["AREA"] . "TRIAL_OF_ASCENSION.png";
  557. }
  558. else{
  559. return URL::IMG["UNKNOWN"];
  560. }
  561. }
  562. else{
  563. if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
  564. return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
  565. }
  566. else{
  567. return URL::IMG["UNKNOWN"];
  568. }
  569. }
  570. }
  571. }
  572. ?>