| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- /**
- * Buildable key entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Buildable.
- *
- * Represents an object from the table 'buildable'.
- *
- * @category Entity
- */
- class Buildable extends Entity{
- /**
- * @var int Buildable identifier.
- */
- public $id;
- /**
- * @var string Buildable name.
- */
- public $name;
- /**
- * @var string Buildable description.
- */
- public $description;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * building, populating it and it's items.
- *
- * @param int $id Buildable identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- id,
- name,
- description
- FROM buildable
- 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"]);
- }
- }
- /**
- * Gets the path to the building image. The image must be in the
- * img/building/ directory, and its name must be the monster id,
- * padded with '0' to 4 digites, and the extension must be '.png'.
- *
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image(){
- return APPLICATION::img("BUILDING", $this->id);
- }
- }
- ?>
|