* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3 * @package SWDB */ require_once(PATH::ENTITY . "Entity.php"); /** * Buildable. * * Represents any of the available buildings in the game. * * Buildings that can be built and leveled up are not considered buildables, but {@link Decorative}. * It does not represent a building owned by the player. * * @category Entity */ class Buildable extends Entity{ /** * @var int Buildable ID. */ private $id; /** * @var string Buildable name. */ private $name; /** * @var string Buildable description. */ private $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"]); } } /** * Retrieves the buildable identifier. * * @return int Buildable ID. */ public function get_id(){ return $this->id; } /** * Retrieves the buildable name. * * @return string Buildable name. */ public function get_name(){ return $this->name; } /** * Retrieves the buildable description. * * @return string Buildable description. */ public function get_description(){ return $this->description; } /** * Gets the path to the building image. * * @return string Image URL, or a fixed unknown image. */ public function get_image(){ return APPLICATION::img("BUILDING", $this->id); } }