| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <?php
- /**
- * Home page file.
- *
- * Provides a class with all the properties and methods to display the page.
- *
- * @category Page
- */
- /**
- * Require dependent files if not present.
- */
- require_once(PATH::PAGE . "Page.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");
- /**
- * Home page model.
- *
- * @category Page
- */
- class Home_Page extends Page{
- /**
- * @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 \Unit[] Unitss in Arena defense.
- */
- public $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 = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @param resource $db Connection to the database.
- * @global int Player ID.
- */
- public function __construct($db){
- global $INVENTORY_TYPE;
- global $UID;
- parent::__construct($db);
- $this->view = PATH::VIEW . "home.php";
- $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
- FROM player
- WHERE uid = '$UID';
- ";
- $q = $this->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($this->db, $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"];
- }
- $s = "
- SELECT unit
- FROM defense
- WHERE uid = '$UID'
- ORDER BY position;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->defense, new Unit($db, $r["unit"], false));
- }
- $s = "
- SELECT DISTINCT building
- FROM building
- WHERE uid = '$UID';
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->building, new Building($db, $r["building"]));
- }
- $s = "
- SELECT decoration
- FROM decoration
- WHERE uid = '$UID';
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->decoration, new Decoration($db, $r["decoration"]));
- }
- $s = "
- SELECT
- id,
- type
- FROM inventory
- WHERE
- uid = '$UID' AND
- type = " . INVENTORY_TYPE_ID::SCROLL . " AND
- amount > 0
- ORDER BY inventory.type;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_scroll, new Inventory($db, $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::RUNE_CRAFT . " AND
- amount > 0
- ORDER BY inventory.id;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_craft_rune, new Inventory($db, $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 = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_craft, new Inventory($db, $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 = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_essence, new Inventory($db, $r["id"], $r["type"]));
- }
- $this->title = "SWDB";
- $this->description = "Summoners War DataBase";
- $this->canonical = URL::BASE;
- }
- }
- ?>
|