0, "crystal" => 0, "energy" => 0, "energy_max" => 0, "arena_energy" => 0, "darkportal_energy" => 0, "dimension_energy" => 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 resource Database connection. */ public function __construct($id, $complete = true){ global $db; $statement = $db->prepare(" SELECT id, server, country, lang, name, level, experience, rep, mana, crystal, energy, energy_max, arena_energy, darkportal_energy, dimension_energy, 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, top_rank_toal FROM player WHERE id = :id; "); $statement->bindValue(':id', $id, SQLITE3_TEXT); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["id"]; $this->server = new K_Server($r["server"]); $this->country = $r["country"]; $this->lang = $r["lang"]; $this->name = $r["name"]; $this->level = $r["level"]; $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["darkportal_energy"] = $r["darkportal_energy"]; $this->currency["dimension_energy"] = $r["dimension_energy"]; $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"]; $this->top_rank_toal = $r["top_rank_toal"]; } $statement = $db->prepare(" SELECT unit FROM data.defense WHERE player = :player AND area_type = :area_type ORDER BY position; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $statement->bindValue(':area_type', AREA_TYPE_ID::ARENA, SQLITE3_INTEGER); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->defense, new Unit($r["unit"], false)); } $statement = $db->prepare(" SELECT unit, position FROM data.defense WHERE player = :player AND area_type = :area_type ORDER BY position; "); $statement->bindValue(':id', $this->id, SQLITE3_TEXT); $statement->bindValue(':area_type', AREA_TYPE_ID::GUILD_WAR, SQLITE3_INTEGER); $q = $statement->execute(); 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)); } } // TODO: Siege defenses $statement = $db->prepare(" SELECT d_building.id AS id, min(d_building.building) AS min FROM data.building d_building, key.building k_building WHERE player = :player AND d_building.building = k_building.id GROUP BY d_building.building; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->building, new Building($r["id"])); } $statement = $db->prepare(" SELECT id FROM data.decoration WHERE player = :player; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->decoration, new Decoration($r["id"])); } $statement = $db->prepare(" SELECT id, type FROM data.inventory WHERE player = :player AND type = :type AND amount > 0 ORDER BY inventory.type; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $statement->bindValue(':type', INVENTORY_TYPE_ID::SCROLL, SQLITE3_TEXT); $q = $statement->execute(); 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. $statement = $db->prepare(" SELECT id, type FROM data.inventory WHERE player = :player AND type = :type AND amount > 0 ORDER BY id; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $statement->bindValue(':type', INVENTORY_TYPE_ID::ENCHANTMENT, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->inventory_craft_rune, new Inventory($r["id"], $r["type"])); } $statement = $db->prepare(" SELECT id, type FROM data.inventory WHERE player = :player AND type = :type AND amount > 0 ORDER BY id; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $statement->bindValue(':type', INVENTORY_TYPE_ID::CRAFT_STUFF, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->inventory_craft, new Inventory($r["id"], $r["type"])); } $statement = $db->prepare(" SELECT d_inventory.id AS id, d_inventory.type AS type FROM data.inventory d_inventory, key.inventory k_inventory WHERE d_inventory.id = k_inventory.id AND d_inventory.type = k_inventory.type AND d_inventory.player = :player AND d_inventory.type = :type AND amount > 0 ORDER BY upper(k_inventory.name) NOT LIKE '%MAGIC%', upper(k_inventory.name) NOT LIKE '%FIRE%', upper(k_inventory.name) NOT LIKE '%WATER%', upper(k_inventory.name) NOT LIKE '%WIND%', upper(k_inventory.name) NOT LIKE '%LIGHT%', upper(k_inventory.name) NOT LIKE '%DARK%', upper(k_inventory.name) NOT LIKE '%LOW%', upper(k_inventory.name) NOT LIKE '%MID%', upper(k_inventory.name) NOT LIKE '%HIGH%' ; "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $statement->bindValue(':type', INVENTORY_TYPE_ID::ESSENCES, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->inventory_essence, new Inventory($r["id"], $r["type"])); } $statement = $db->prepare(" SELECT player, area_type, area FROM data.record WHERE player = :player 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 "); $statement->bindValue(':player', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->record, new Record($r["player"], $r["area_type"], $r["area"])); } } } ?>