| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- require_once($path["entity"] . "Entity.php");
- require_once($path["entity"] . "Monster_Base.php");
-
- /**
- * Monster.
- *
- * Represents an object from the table 'monster'.
- */
- class Monster extends Entity{
- /**
- * Project 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;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * monster, populating it and it's items.
- *
- * @param MySQL_connection $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 " .
- "FROM monster " .
- "WHERE id = $id; ";
- $q = mysqli_query($this->db, $s);
- if (mysqli_num_rows($q) > 0){
- $r = mysqli_fetch_array($q);
- $this->id = $r["id"];
- $this->name = $r["name"];
- $this->name_aw = $r["name_aw"];
- $this->element = $r["element"];
- $this->stars = $r["stars"];
- $this->base = new Monster_Base($this->db, $r["base"]);
- $this->image = $path["img"]["monster"] . str_pad($id, 4, '0', STR_PAD_LEFT) . ".png";
- $this->image_aw = $path["img"]["awaken"] . str_pad($id, 4, '0', STR_PAD_LEFT) . ".png";
- }
- }
- }
- ?>
|