| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- require_once($path["page"] . "Page.php");
- require_once($path["entity"] . "K_Monster.php");
- /**
- * Monster details page.
- */
- class Monster_Info_Page extends Page{
- /**
- * Selected @{see Monster}0
- * [0]: Unawakened monster (null if default purple).
- * [1]: Awakened monster (null if silver).
- * [2]: Second awakened monster (null if unavailaable).
- */
- public $monster = [];
- /**
- * IDs to other monsters of thef family
- */
- public $family = [
- "Fire" => null,
- "Water" => null,
- "Wind" => null,
- "Light" => null,
- "Dark" => null,
- ];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @param SQLite3 $db Connection to the database.
- * @param string $id Monster id. Can be any of the awakening stages
- */
- public function __construct($db, $id){
- global $path;
- global $root;
- parent::__construct($db);
- $this->view = $path["view"] . "monster_info.php";
- $title = "";
- $monster = new K_Monster($db, $id);
- if ($monster->can_awaken == 0){
- // Silver star monster.
- $this->monster[0] = $monster;
- $this->monster[1] = null;
- $this->monster[2] = null;
- $title = $this->monster[0]->element . " " . $this->monster[0]->name;
- }
- elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
- // Default purple (Rainbowmon or King Angelmon)
- $this->monster[0] = null;
- $this->monster[1] = $monster;
- $this->monster[2] = null;
- $title = $this->monster[1]->name;
- }
- elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
- // Normal monster, already awakened, no 2a.
- $this->monster[0] = new K_Monster($db, $monster->awakens_from);
- $this->monster[1] = $monster;
- $this->monster[2] = null;
- $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
- $monster = $this->monster[0];
- }
- elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
- // Normal monster, not awakened, may have 2a.
- $this->monster[0] = $monster;
- $this->monster[1] = new K_Monster($db, $this->monster[0]->awakens_to);
- if ($this->monster[1]->awakens_to == ""){
- $this->monster[2] = null;
- }
- else{
- $this->monster[2] = new K_Monster($db, $this->monster[1]->awakens_to);
- }
- $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
- }
- $s =
- "SELECT " .
- " id, " .
- " element " .
- "FROM k_monster " .
- "WHERE " .
- " family_id = " . $monster->family_id . " AND " .
- " element <> '" . $monster->element . "';";
- $q_mon = $this->db->query($s);
- while ($r = $q_mon->fetchArray(SQLITE3_ASSOC)){
- $this->family[$r["element"]] = $r["id"];
- }
- $this->title = $title ." - SWDB";
- $this->description = $title . " info - SWDB";
- $this->canonical = $root . "monster_info/" . $id;
- }
- }
- ?>
|