| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- <?php
- /**
- * Area type entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * An area.
- *
- * Represents an object from the table 'k_area'.
- *
- * @category Entity
- */
- class K_Area extends Entity{
- /**
- * @var int Area identifier (it may not be unique!).
- */
- public $id;
- /**
- * @var int Area type.
- */
- public $type;
- /**
- * @var string Area name.
- */
- public $name;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * run, populating it and it's items.
- *
- * @param resource $db Connection to the database.
- * @param int $id Area identifier.
- * @param int $type Area type (required).
- */
- public function __construct($db, $id, $type){
- parent::__construct($db);
- $this->id = $id;
- $this->type = $type;
- $s = "
- SELECT
- id,
- type,
- name
- FROM k_area
- WHERE
- id = '$id' AND
- type = '$type'
- ORDER BY type = '$type' DESC;
- ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->name = HTML::e($r["name"]);
- }
- elseif($this->id > 1000){
- $this->type = AREA_TYPE_ID::CAIROS_DUNGEON;
- $this->name = "Hall of Heroes";
- }
- }
- /**
- * Gets the path to the area image. The image must be in the
- * img/area/ directory, and its name must be the area type id,
- * padded with '0' to 9 digites, and the extension must be '.png'.
- *
- * @param string $stage Stage number, for a better image in Cairos.
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image($stage = null){
- if ($this->id > 10000 && file_exists(PATH::BASE . "img/area/HOH.png")){
- // Hall of Heroes
- return URL::IMG["AREA"] . "HOH.png";
- }
- elseif (
- (
- $this->type == AREA_TYPE_ID::SCENARIO ||
- //$this->type == AREA_TYPE_ID::RIFT_DUNGEON ||
- //$this->type == AREA_TYPE_ID::DIMENSIONAL_HOLE ||
- //$this->type == AREA_TYPE_ID::RIFT_RAID ||
- $this->type == AREA_TYPE_ID::ARENA ||
- $this->type == AREA_TYPE_ID::GUILD_WAR ||
- $this->type == AREA_TYPE_ID::GUILD_SIEGE ||
- //$this->type == AREA_TYPE_ID::TARTARUS_LABYRINTH ||
- //$this->type == AREA_TYPE_ID::TRIAL_OF_ASCENSION ||
- $this->type == AREA_TYPE_ID::WORLD_BOSS ||
- $this->type == AREA_TYPE_ID::DIMENSIONAL_RIFT
- ) && file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")
- ){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- elseif ($this->type == AREA_TYPE_ID::CAIROS_DUNGEON && APPLICATION::valid_id("DUNGEON_ID", $this->id)){
- switch ($this->id){
- case DUNGEON_ID::GIANTS_KEEP:
- switch ($stage){
- case 1:
- case 6:
- // Light
- if (file_exists(PATH::BASE . "img/unit/00060204.png")){
- return URL::IMG["UNIT"] . "00060204.png";
- }
- break;
- break;
- case 2:
- case 7:
- // Dark
- if (file_exists(PATH::BASE . "img/unit/00060204.png")){
- return URL::IMG["UNIT"] . "00060204.png";
- }
- break;
- case 3:
- case 8:
- // Wind
- if (file_exists(PATH::BASE . "img/unit/00060203.png")){
- return URL::IMG["UNIT"] . "00060203.png";
- }
- break;
- case 4:
- case 9:
- // Fire
- if (file_exists(PATH::BASE . "img/unit/00060202.png")){
- return URL::IMG["UNIT"] . "00060202.png";
- }
- break;
- case 5:
- case 10:
- // Water
- if (file_exists(PATH::BASE . "img/unit/00060201.png")){
- return URL::IMG["UNIT"] . "00060201.png";
- }
- break;
- }
- break;
- case DUNGEON_ID::DRAGONS_LAIR:
- switch ($stage){
- case 1:
- case 6:
- // Wind
- if (file_exists(PATH::BASE . "img/unit/00060303.png")){
- return URL::IMG["UNIT"] . "00060303.png";
- }
- break;
- break;
- case 2:
- case 7:
- // Light
- if (file_exists(PATH::BASE . "img/unit/00060304.png")){
- return URL::IMG["UNIT"] . "00060304.png";
- }
- break;
- case 3:
- case 8:
- // Water
- if (file_exists(PATH::BASE . "img/unit/00060301.png")){
- return URL::IMG["UNIT"] . "00060301.png";
- }
- break;
- case 4:
- case 9:
- // Dark
- if (file_exists(PATH::BASE . "img/unit/00060305.png")){
- return URL::IMG["UNIT"] . "00060305.png";
- }
- break;
- case 5:
- case 10:
- // Fire
- if (file_exists(PATH::BASE . "img/unit/00060302.png")){
- return URL::IMG["UNIT"] . "00060302.png";
- }
- break;
- }
- break;
- case DUNGEON_ID::NECROPOLIS:
- switch ($stage){
- case 1:
- case 6:
- // Water
- if (file_exists(PATH::BASE . "img/unit/00062101.png")){
- return URL::IMG["UNIT"] . "00062101.png";
- }
- break;
- break;
- case 2:
- case 7:
- // Fire
- if (file_exists(PATH::BASE . "img/unit/00062102.png")){
- return URL::IMG["UNIT"] . "00062102.png";
- }
- break;
- case 3:
- case 8:
- // Wind
- if (file_exists(PATH::BASE . "img/unit/00062103.png")){
- return URL::IMG["UNIT"] . "00062103.png";
- }
- break;
- case 4:
- case 9:
- // Light
- if (file_exists(PATH::BASE . "img/unit/00062104.png")){
- return URL::IMG["UNIT"] . "00062104.png";
- }
- break;
- case 5:
- case 10:
- // Dark
- if (file_exists(PATH::BASE . "img/unit/00062105.png")){
- return URL::IMG["UNIT"] . "00062105.png";
- }
- break;
- }
- break;
- case DUNGEON_ID::HALL_OF_WATER:
- if (file_exists(PATH::BASE . "img/unit/00060101.png")){
- return URL::IMG["UNIT"] . "00060101.png";
- }
- break;
- case DUNGEON_ID::HALL_OF_FIRE:
- if (file_exists(PATH::BASE . "img/unit/00060102.png")){
- return URL::IMG["UNIT"] . "00060102.png";
- }
- break;
- case DUNGEON_ID::HALL_OF_WIND:
- if (file_exists(PATH::BASE . "img/unit/00060103.png")){
- return URL::IMG["UNIT"] . "00060103.png";
- }
- break;
- case DUNGEON_ID::HALL_OF_LIGHT:
- if (file_exists(PATH::BASE . "img/unit/00060104.png")){
- return URL::IMG["UNIT"] . "00060104.png";
- }
- break;
- case DUNGEON_ID::HALL_OF_DARK:
- if (file_exists(PATH::BASE . "img/unit/00060105.png")){
- return $PATH["IMG"]["UNIT"] . "00060105.png";
- }
- break;
- case DUNGEON_ID::HALL_OF_MAGIC:
- if (file_exists(PATH::BASE . "img/unit/00062004.png")){
- return URL::IMG["UNIT"] . "00062004.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- }
- }
- elseif ($this->type == AREA_TYPE_ID::RIFT_DUNGEON && APPLICATION::valid_id("ELEMENTAL_RIFT_DUNGEON_ID", $this->id)){
- switch ($this->id){
- case ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST:
- if (file_exists(PATH::BASE . "img/unit/00043001.png")){
- return URL::IMG["UNIT"] . "00043001.png";
- }
- break;
- case ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST:
- if (file_exists(PATH::BASE . "img/unit/00043002.png")){
- return URL::IMG["UNIT"] . "00043002.png";
- }
- break;
- case ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST:
- if (file_exists(PATH::BASE . "img/unit/00043003.png")){
- return URL::IMG["UNIT"] . "00043003.png";
- }
- break;
- case ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST:
- if (file_exists(PATH::BASE . "img/unit/00043004.png")){
- return URL::IMG["UNIT"] . "00043004.png";
- }
- break;
- case ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST:
- if (file_exists(PATH::BASE . "img/unit/00043005.png")){
- return URL::IMG["UNIT"] . "00043005.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- }
- elseif ($this->type == AREA_TYPE_ID::RIFT_RAID){
- if (file_exists(PATH::BASE . "img/unit/00044007.png")){
- return URL::IMG["UNIT"] . "00044007.png";
- }
- }
- elseif ($this->type == AREA_TYPE_ID::DIMENSIONAL_HOLE){
- switch ($this->id){
- case DUNGEON_ID::FOREST_OF_ROARING_BEASTS:
- if (file_exists(PATH::BASE . "img/unit/00047002.png")){
- return URL::IMG["UNIT"] . "00047002.png";
- }
- break;
- case DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES:
- if (file_exists(PATH::BASE . "img/unit/00047001.png")){
- return URL::IMG["UNIT"] . "00047001.png";
- }
- break;
- case DUNGEON_ID::CLIFF_OF_TOUGH_BEASTS_MEN:
- if (file_exists(PATH::BASE . "img/unit/00047002.png")){
- return URL::IMG["UNIT"] . "00047003.png";
- }
- break;
- case DUNGEON_ID::KARZHAN_REMAINS_WARBEAR:
- switch ($stage){
- case 1:
- if (file_exists(PATH::BASE . "img/unit/00010734.png")){
- return URL::IMG["UNIT"] . "00010734.png";
- }
- break;
- case 2:
- if (file_exists(PATH::BASE . "img/unit/00010733.png")){
- return URL::IMG["UNIT"] . "00010733.png";
- }
- break;
- case 3:
- if (file_exists(PATH::BASE . "img/unit/00010731.png")){
- return URL::IMG["UNIT"] . "00010731.png";
- }
- break;
- case 4:
- if (file_exists(PATH::BASE . "img/unit/00010735.png")){
- return URL::IMG["UNIT"] . "00010735.png";
- }
- break;
- case 5:
- if (file_exists(PATH::BASE . "img/unit/00010732.png")){
- return URL::IMG["UNIT"] . "00010732.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- break;
- case DUNGEON_ID::KARZHAN_REMAINS_INUGAMI:
- switch ($stage){
- case 1:
- if (file_exists(PATH::BASE . "img/unit/00011031.png")){
- return URL::IMG["UNIT"] . "00011031.png";
- }
- break;
- case 2:
- if (file_exists(PATH::BASE . "img/unit/00011033.png")){
- return URL::IMG["UNIT"] . "00011033.png";
- }
- break;
- case 3:
- if (file_exists(PATH::BASE . "img/unit/00011032.png")){
- return URL::IMG["UNIT"] . "00011032.png";
- }
- break;
- case 4:
- if (file_exists(PATH::BASE . "img/unit/00011034.png")){
- return URL::IMG["UNIT"] . "00011034.png";
- }
- break;
- case 5:
- if (file_exists(PATH::BASE . "img/unit/00011035.png")){
- return URL::IMG["UNIT"] . "00011035.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- break;
- case DUNGEON_ID::ELLUNIA_REMAINS_FAIRY:
- switch ($stage){
- case 1:
- if (file_exists(PATH::BASE . "img/unit/00010132.png")){
- return URL::IMG["UNIT"] . "00010132.png";
- }
- break;
- case 2:
- if (file_exists(PATH::BASE . "img/unit/00010134.png")){
- return URL::IMG["UNIT"] . "00010134.png";
- }
- break;
- case 3:
- if (file_exists(PATH::BASE . "img/unit/00010131.png")){
- return URL::IMG["UNIT"] . "00010131.png";
- }
- break;
- case 4:
- if (file_exists(PATH::BASE . "img/unit/00010133.png")){
- return URL::IMG["UNIT"] . "00010133.png";
- }
- break;
- case 5:
- if (file_exists(PATH::BASE . "img/unit/00010134.png")){
- return URL::IMG["UNIT"] . "00010134.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- break;
- case DUNGEON_ID::ELLUNIA_REMAINS_PIXIE:
- switch ($stage){
- case 1:
- if (file_exists(PATH::BASE . "img/unit/00010334.png")){
- return URL::IMG["UNIT"] . "00010334.png";
- }
- break;
- case 2:
- if (file_exists(PATH::BASE . "img/unit/00010332.png")){
- return URL::IMG["UNIT"] . "00010332.png";
- }
- break;
- case 3:
- if (file_exists(PATH::BASE . "img/unit/00010335.png")){
- return URL::IMG["UNIT"] . "00010335.png";
- }
- break;
- case 4:
- if (file_exists(PATH::BASE . "img/unit/00010333.png")){
- return URL::IMG["UNIT"] . "00010333.png";
- }
- break;
- case 5:
- if (file_exists(PATH::BASE . "img/unit/00010331.png")){
- return URL::IMG["UNIT"] . "00010331.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- break;
- case DUNGEON_ID::LUMEL_REMAINS_WEREWOLF:
- switch ($stage){
- case 1:
- if (file_exists(PATH::BASE . "img/unit/00014035.png")){
- return URL::IMG["UNIT"] . "00014035.png";
- }
- break;
- case 2:
- if (file_exists(PATH::BASE . "img/unit/00014033.png")){
- return URL::IMG["UNIT"] . "00014033.png";
- }
- break;
- case 3:
- if (file_exists(PATH::BASE . "img/unit/00014031.png")){
- return URL::IMG["UNIT"] . "00014031.png";
- }
- break;
- case 4:
- if (file_exists(PATH::BASE . "img/unit/00014034.png")){
- return URL::IMG["UNIT"] . "00014034.png";
- }
- break;
- case 5:
- if (file_exists(PATH::BASE . "img/unit/00014032.png")){
- return URL::IMG["UNIT"] . "00014032.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- break;
- case DUNGEON_ID::LUMEL_REMAINS_MARTIAL_CAT:
- switch ($stage){
- case 1:
- if (file_exists(PATH::BASE . "img/unit/00015032.png")){
- return URL::IMG["UNIT"] . "00015032.png";
- }
- break;
- case 2:
- if (file_exists(PATH::BASE . "img/unit/00015034.png")){
- return URL::IMG["UNIT"] . "00015034.png";
- }
- break;
- case 3:
- if (file_exists(PATH::BASE . "img/unit/00015031.png")){
- return URL::IMG["UNIT"] . "00015031.png";
- }
- break;
- case 4:
- if (file_exists(PATH::BASE . "img/unit/00015035.png")){
- return URL::IMG["UNIT"] . "00015035.png";
- }
- break;
- case 5:
- if (file_exists(PATH::BASE . "img/unit/00015033.png")){
- return URL::IMG["UNIT"] . "00015033.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- break;
- }
- }
- elseif ($this->type == AREA_TYPE_ID::TARTARUS_LABYRINTH){
- switch ($stage){
- case LABYRINTH_STAGES_ID::TARTARUS:
- if (file_exists(PATH::BASE . "img/unit/00046001.png")){
- return URL::IMG["UNIT"] . "00046001.png";
- }
- break;
- case LABYRINTH_STAGES_ID::LEOS:
- if (file_exists(PATH::BASE . "img/unit/00046101.png")){
- return URL::IMG["UNIT"] . "00046101.png";
- }
- break;
- case LABYRINTH_STAGES_ID::KOTTOS:
- if (file_exists(PATH::BASE . "img/unit/00046102.png")){
- return URL::IMG["UNIT"] . "00046102.png";
- }
- break;
- case LABYRINTH_STAGES_ID::AQUILES:
- if (file_exists(PATH::BASE . "img/unit/00046103.png")){
- return URL::IMG["UNIT"] . "00046103.png";
- }
- break;
- default:
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- else{
- return URL::IMG["UNKNOWN"];
- }
- }
- }
- elseif ($this->type == AREA_TYPE_ID::TRIAL_OF_ASCENSION){
- if (file_exists(PATH::BASE . "img/area/TRIAL_OF_ASCENSION.png")){
- return URL::IMG["AREA"] . "TRIAL_OF_ASCENSION.png";
- }
- else{
- return URL::IMG["UNKNOWN"];
- }
- }
- else{
- if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
- return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
- }
- else{
- return URL::IMG["UNKNOWN"];
- }
- }
- }
- }
- ?>
|