| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <?php
- 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.
- */
- class Home_Page extends Page{
- /**
- * Player ID.
- */
- public $uid;
- /**
- * Player name.
- */
- public $name;
- /**
- * Player country (XX).
- */
- public $country;
- /**
- * Total experience.
- */
- public $experience;
- /**
- * Representative {@see Unit}.
- */
- public $rep;
- /**
- * {@see Unit}s in Arena defense.
- */
- public $defense = [];
- /**
- * 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,
- ];
- /**
- * List of {@see Building}s.
- */
- public $building = [];
- /**
- * List of {@see Decoration}s.
- */
- public $decoration = [];
- /**
- * List of Scrolls in {@see Inventory}s.
- */
- public $inventory_scroll = [];
- /**
- * List of rune crafting items in {@see Inventory}s.
- */
- public $inventory_craft_rune = [];
- /**
- * List of rune crafting items in {@see Inventory}s.
- */
- public $inventory_craft = [];
- /**
- * List of rune crafting items in {@see Inventory}s.
- */
- public $inventory_essence = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @param SQLite3 $db Connection to the database.
- * @param string $lang Lowercase, two-letter language code.
- */
- public function __construct($db){
- global $path;
- global $root;
- global $INVENTORY_TYPE;
- global $UID;
- parent::__construct($db);
- $this->view = $path["view"] . "home.php";
- $s = "
- SELECT
- uid,
- name,
- 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->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
- FROM inventory
- WHERE
- uid = '$UID' AND
- type = " . $INVENTORY_TYPE["SCROLL"] . " AND
- amount > 0;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_scroll, new Inventory($db, $r["id"]));
- }
- // Rune crafting items are marked as generic crafting.
- $s = "
- SELECT inventory.id
- FROM
- inventory,
- k_inventory
- WHERE
- inventory.uid = '$UID' AND
- inventory.id = k_inventory.id AND
- k_inventory.type = " . $INVENTORY_TYPE["RUNE_CRAFT"] . " AND
- amount > 0;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_craft_rune, new Inventory($db, $r["id"]));
- }
- $s = "
- SELECT inventory.id
- FROM
- inventory,
- k_inventory
- WHERE
- inventory.uid = '$UID' AND
- inventory.id = k_inventory.id AND
- k_inventory.type = " . $INVENTORY_TYPE["CRAFT_STUFF"] . " AND
- amount > 0;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->inventory_craft, new Inventory($db, $r["id"]));
- }
- $s = "
- SELECT inventory.id AS id
- FROM
- inventory,
- k_inventory
- WHERE
- inventory.uid = '$UID' AND
- k_inventory.id = inventory.id AND
- k_inventory.type = " . $INVENTORY_TYPE["ESSENCES"] . "
- 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"]));
- }
- $this->title = "SWDB";
- $this->description = "Summoners War DataBase";
- $this->canonical = $root;
- }
- }
- ?>
|