| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- require_once($path["entity"] . "Entity.php");
- require_once($path["entity"] . "Monster_Base.php");
- require_once($path["entity"] . "Monster_Skill.php");
- /**
- * Monster.
- *
- * Represents an object from the table 'monster'.
- */
- class Monster extends Entity{
- /**
- * Skill identifier.
- */
- public $id;
- /**
- * Monster name.
- */
- public $name;
- /**
- * Monster name (awakened).
- */
- public $name_aw;
- /**
- * Monster element.
- */
- public $element;
- /**
- * Default star level.
- */
- public $stars;
- /**
- * Base monster. {@see Monster_Base}
- */
- public $base;
- /**
- * Monster image.
- */
- public $image;
- /**
- * Monster image (awakened).
- */
- public $image_aw;
- /**
- * All {@see Monster_Skill}
- */
- public $skill = [];
- /*
- * Indicates if the monster can be awakened.
- */
- public $awakeable;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * monster, populating it and it's items.
- *
- * @param SQLite3 $db Connection to the database.
- * @param int $id Monster identifier.
- */
- public function __construct($db, $id){
- global $path;
- parent::__construct($db);
- $s =
- "SELECT " .
- " id, " .
- " name, " .
- " name_aw, " .
- " element, " .
- " stars, " .
- " base, " .
- " img, " .
- " img_aw, " .
- " awakeable " .
- "FROM monster " .
- "WHERE id = $id; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->name = $r["name"];
- $this->name_aw = $r["name_aw"];
- $this->element = $r["element"];
- $this->stars = $r["stars"];
- $this->awakeable = $r["awakeable"];
- $this->base = new Monster_Base($this->db, $r["base"]);
- $this->image = $path["img"]["monster"] . $r["img"];
- $this->image_aw = $path["img"]["monster"] . $r["img_aw"];
- }
- $s =
- "SELECT " .
- " id " .
- "FROM monster_skill " .
- "WHERE " .
- " monster = $id AND" .
- " upgrade IS NULL " .
- "ORDER BY idx; ";
- error_log($s);
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->skill, new Monster_Skill($this->db, $r["id"]));
- }
- }
- }
- ?>
|