| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * Monster source entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Monster source.
- *
- * Represents an object from the table 'source'.
- *
- * @category Entity
- */
- class Source extends Entity{
- /**
- * @var int Source identifier.
- */
- public $id;
- /**
- * @var string Source name.
- */
- public $name;
- /**
- * @var string Source description.
- */
- public $description;
- /**
- * @var bool Indicates if the source is farmable.
- */
- public $farmable;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * source, populating it and it's items.
- *
- * @param int $id Surce identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- id,
- name,
- description,
- farmable
- FROM source
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->name = HTML::e($r["name"]);
- $this->description = HTML::e($r["description"]);
- $this->farmable_source = $r["farmable"];
- }
- }
- /**
- * Gets the path to the source image. The image must be in the
- * img/source/ directory, and it's name must be the source id,
- * padded with '0' to 4 digits, and the extension must be '.png'.
- *
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image(){
- return APPLICATION::img("SOURCE", $this->id);
- }
- }
- ?>
|