| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <?php
- /**
- * Player entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- require_once(PATH::ENTITY . "Unit.php");
- require_once(PATH::ENTITY . "Building.php");
- require_once(PATH::ENTITY . "Decoration.php");
- require_once(PATH::ENTITY . "Inventory.php");
- require_once(PATH::ENTITY . "Record.php");
- /**
- * A Unit.
- *
- * Represents an object from the table 'unit'.
- *
- * @category Entity
- */
- class Player extends Entity{
- /**
- * @var int Player ID.
- */
- public $uid;
- /**
- * @var int Player level.
- */
- public $level;
- /**
- * @var string Player name.
- */
- public $name;
- /**
- * @var string Player country (XX).
- */
- public $country;
- /**
- * @var int Total experience.
- */
- public $experience;
- /**
- * @var Unit Representative Unit.
- */
- public $rep;
- /**
- * @var int Timestamp of player registration.
- */
- public $joined = 0;
- /**
- * @var int Top rank in arena.
- */
- public $top_rank_arena = 0;
- /**
- * @var int Top rank in world arena.
- */
- public $top_rank_world_arena = 0;
- /**
- * @var int Top rank in special league.
- */
- public $top_rank_special_league = 0;
- /**
- * @var int Top rank in guild war.
- */
- public $top_rank_gw = 0;
- /**
- * @var int Top rank in guild siege.
- */
- public $top_rank_siege = 0;
- /**
- * @var int Top rank in World Boss.
- */
- public $top_rank_wboss = 0;
- /**
- * @var int Top rank in TOA normal.
- */
- public $top_rank_toan = 0;
- /**
- * @var int Top rank in TOA HARD.
- */
- public $top_rank_toah = 0;
- /**
- * @var \Unit[] Units in Arena defense.
- */
- public $defense = [];
- /**
- * @var \Unit[] Units in Arena defense.
- */
- public $gw_defense = [[], []];
- /**
- * @var int[] Currency.
- */
- public $currency = [
- "mana" => 0,
- "crystal" => 0,
- "energy" => 0,
- "energy_max" => 0,
- "arena_energy" => 0,
- "arena_energy_max" => 0,
- "darkportal_energy" => 0,
- "darkportal_energy_max" => 0,
- "dimension_energy" => 0,
- "dimension_energy_max" => 0,
- "honor_point" => 0,
- "guild_point" => 0,
- "honor_medal" => 0,
- "honor_mark" => 0,
- "event_coin" => 0,
- "social_point" => 0,
- "ancient_stone" => 0,
- "costume_point" => 0,
- ];
- /**
- * @var \Building[] List of Buildings.
- */
- public $building = [];
- /**
- * @var \Decoration[] List of Decorations.
- */
- public $decoration = [];
- /**
- * @var \Inventory[] List of Scrolls in Inventory.
- */
- public $inventory_scroll = [];
- /**
- * @var \Inventory[] List of rune crafting items in Inventory.
- */
- public $inventory_craft_rune = [];
- /**
- * @var \Inventory[] List of rune crafting items in Inventory.
- */
- public $inventory_craft = [];
- /**
- * @var \Inventory[] List of rune crafting items in Inventory.
- */
- public $inventory_essence = [];
- /**
- * @var \Record[] Player record runs.
- */
- public $record = [];
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * player, populating it and it's items.
- *
- * @param int $id Monster identifier.
- * @param bool $complete If false, query only monster and k_monster.
- * @global int Player ID.
- * @global resource Database connection.
- */
- public function __construct($id, $complete = true){
- global $UID;
- global $db;
- $s = "
- SELECT
- uid,
- name,
- level,
- country,
- experience,
- rep,
- mana,
- crystal,
- energy,
- energy_max,
- arena_energy,
- arena_energy_max,
- darkportal_energy,
- darkportal_energy_max,
- dimension_energy,
- dimension_energy_max,
- honor_point,
- guild_point,
- honor_medal,
- honor_mark,
- event_coin,
- social_point,
- costume_point,
- joined,
- top_rank_arena,
- top_rank_world_arena,
- top_rank_special_league,
- top_rank_gw,
- top_rank_siege,
- top_rank_wboss,
- top_rank_toan,
- top_rank_toah
- FROM player
- WHERE uid = '$UID';
- ";
- $q = $db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->uid = $r["uid"];
- $this->name = $r["name"];
- $this->level = $r["level"];
- $this->country = $r["country"];
- $this->experience = $r["experience"];
- if (strlen($r["rep"]) > 0){
- $this->rep = new Unit($r["rep"]);
- }
- $this->currency["mana"] = $r["mana"];
- $this->currency["crystal"] = $r["crystal"];
- $this->currency["energy"] = $r["energy"];
- $this->currency["energy_max"] = $r["energy_max"];
- $this->currency["arena_energy"] = $r["arena_energy"];
- $this->currency["arena_energy_max"] = $r["arena_energy_max"];
- $this->currency["darkportal_energy"] = $r["darkportal_energy"];
- $this->currency["darkportal_energy_max"] = $r["darkportal_energy_max"];
- $this->currency["dimension_energy"] = $r["dimension_energy"];
- $this->currency["dimension_energy_max"] = $r["dimension_energy_max"];
- $this->currency["honor_point"] = $r["honor_point"];
- $this->currency["guild_point"] = $r["guild_point"];
- $this->currency["honor_medal"] = $r["honor_medal"];
- $this->currency["honor_mark"] = $r["honor_mark"];
- $this->currency["event_coin"] = $r["event_coin"];
- $this->currency["social_point"] = $r["social_point"];
- $this->currency["costume_point"] = $r["costume_point"];
- $this->joined = $r["joined"];
- $this->top_rank_arena = $r["top_rank_arena"];
- $this->top_rank_world_arena = $r["top_rank_world_arena"];
- $this->top_rank_special_league = $r["top_rank_special_league"];
- $this->top_rank_gw = $r["top_rank_gw"];
- $this->top_rank_siege = $r["top_rank_siege"];
- $this->top_rank_wboss = $r["top_rank_wboss"];
- $this->top_rank_toan = $r["top_rank_toan"];
- $this->top_rank_toah = $r["top_rank_toah"];
- }
- $s = "
- SELECT unit
- FROM defense
- WHERE uid = '$UID'
- ORDER BY position;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->defense, new Unit($r["unit"], false));
- }
- $s = "
- SELECT
- unit,
- position
- FROM gw_defense
- WHERE uid = '$UID'
- ORDER BY position;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- if ($r["position"] <= 3){
- array_push($this->gw_defense[0], new Unit($r["unit"], false));
- }
- else{
- array_push($this->gw_defense[1], new Unit($r["unit"], false));
- }
- }
- $s = "
- SELECT
- building.id,
- min(building)
- FROM
- building,
- k_building
- WHERE
- uid = '$UID' AND
- building.building = k_building.id
- GROUP BY building.building;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->building, new Building($r["id"]));
- }
- $s = "
- SELECT id
- FROM decoration
- WHERE uid = '$UID';
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->decoration, new Decoration($r["id"]));
- }
- $s = "
- SELECT
- id,
- type
- FROM inventory
- WHERE
- uid = '$UID' AND
- type = " . INVENTORY_TYPE_ID::SCROLL . " AND
- amount > 0
- ORDER BY inventory.type;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_scroll, new Inventory($r["id"], $r["type"]));
- }
- // Rune crafting items are marked as generic crafting.
- $s = "
- SELECT
- inventory.id AS id,
- inventory.type AS type
- FROM
- inventory
- WHERE
- inventory.uid = '$UID' AND
- inventory.type = " . INVENTORY_TYPE_ID::ENCHANTMENT . " AND
- amount > 0
- ORDER BY inventory.id;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_craft_rune, new Inventory($r["id"], $r["type"]));
- }
- $s = "
- SELECT
- inventory.id AS id,
- inventory.type AS type
- FROM
- inventory
- WHERE
- inventory.uid = '$UID' AND
- inventory.type = " . INVENTORY_TYPE_ID::CRAFT_STUFF . " AND
- amount > 0
- ORDER BY inventory.id;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_craft, new Inventory($r["id"], $r["type"]));
- }
- $s = "
- SELECT
- inventory.id AS id,
- inventory.type AS type
- FROM
- inventory,
- k_inventory
- WHERE
- inventory.id = k_inventory.id AND
- inventory.type = k_inventory.type AND
- inventory.uid = '$UID' AND
- inventory.type = " . INVENTORY_TYPE_ID::ESSENCES . " AND
- amount > 0
- ORDER BY
- upper(name) NOT LIKE '%MAGIC%',
- upper(name) NOT LIKE '%FIRE%',
- upper(name) NOT LIKE '%WATER%',
- upper(name) NOT LIKE '%WIND%',
- upper(name) NOT LIKE '%LIGHT%',
- upper(name) NOT LIKE '%DARK%',
- upper(name) NOT LIKE '%LOW%',
- upper(name) NOT LIKE '%MID%',
- upper(name) NOT LIKE '%HIGH%'
- ;
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_essence, new Inventory($r["id"], $r["type"]));
- }
- $s = "
- SELECT
- uid,
- area_type,
- area
- FROM record
- WHERE uid = '$UID'
- ORDER BY
- CASE
- WHEN (area_type = 2 AND area = 8001) THEN 1 -- Giant's Keep
- WHEN (area_type = 2 AND area = 9001) THEN 2 -- Dragon's Lair
- WHEN (area_type = 2 AND area = 6001) THEN 3 -- Necropolis
- WHEN (area_type = 2 AND area = 9501) THEN 4 -- Steel Fortress
- WHEN (area_type = 2 AND area = 9502) THEN 5 -- Punisher's Crypt
- WHEN (area_type = 4) THEN 6 -- Rift of Worlds
- WHEN (area_type = 3 AND area = 1001) THEN 7 -- Rift Dungeon - Ice Beast
- WHEN (area_type = 3 AND area = 2001) THEN 8 -- Rift Dungeon - Fire Beast
- WHEN (area_type = 3 AND area = 3001) THEN 9 -- Rift Dungeon - Wind Beast
- WHEN (area_type = 3 AND area = 4001) THEN 10 -- Rift Dungeon - Light Beast
- WHEN (area_type = 3 AND area = 5001) THEN 11 -- Rift Dungeon - Dark Beast
- WHEN (area_type = 2 AND area = 5001) THEN 12 -- Hall of Magic
- WHEN (area_type = 2 AND area = 3001) THEN 13 -- Hall of Water
- WHEN (area_type = 2 AND area = 2001) THEN 14 -- Hall of Fire
- WHEN (area_type = 2 AND area = 4001) THEN 15 -- Hall of Wind
- WHEN (area_type = 2 AND area = 7001) THEN 16 -- Hall of Light
- WHEN (area_type = 2 AND area = 1001) THEN 17 -- Hall of Dark
- ELSE area
- END ASC
- ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->record, new Record($r["uid"], $r["area_type"], $r["area"]));
- }
- }
- }
- ?>
|