| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- /**
- * Building entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- require_once(PATH::ENTITY . "Buildable.php");
- /**
- * A Building.
- *
- * Represents an object from the table 'building'.
- *
- * @category Entity
- */
- class Building extends Entity{
- private $player_id;
- private $buildable;
- private $gain;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * building, populating it and it's items.
- *
- * @param int $id Building identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- player,
- buildable,
- gain
- FROM building
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->player = $r["player"];
- $this->buildable = new Buildable($r["buildable"]);
- $this->gain = $r["gain"];
- }
- }
- /**
- * Retrieves the player identifier of the owner
- *
- * @return int Player ID.
- */
- public function get_player(){
- return $this->player_id;
- }
-
- /**
- * Retrieves the base buildable.
- *
- * @return Buildable Base buildable.
- */
- public function get_buildable(){
- return $this->buildable;
- }
-
- /**
- * Retrieves the gain per hour, on whatever the building provides.
- *
- * @return number Gain per hour.
- */
- public function get_gain(){
- return $this->gain;
- }
-
- }
- ?>
|