| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- /**
- * Decoration entity file.
- *
- * Creates the entity and makes it available.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- */
- require_once(PATH::ENTITY . "Entity.php");
- require_once(PATH::ENTITY . "Decorative.php");
- /**
- * A decoration.
- *
- * Represents a decoration owned by a player.
- * Decorations are buildings that can be built and leveled up. If it can't be leveled up, it's not
- * a decoration, but a {@link Building}.
- *
- * @category Entity
- */
- class Decoration extends Entity{
- /**
- * @var int Owner's player ID.
- */
- private $player_id;
- /**
- * @var Decorative Base decorative.
- */
- private $decorative;
- /**
- * @var int Current level.
- */
- private $level;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * decoration, populating it and it's items.
- *
- * @param int $id Building identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- player,
- decorative,
- level
- FROM decoration
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->player = $r["player"];
- $this->decorative = new Decorative($r["decorative"]);
- $this->level = $r["level"];
- }
- }
- /**
- * Retrieves the owner's player id.
- *
- * @return int Player ID.
- */
- public function get_player_id(){
- return $this->player_id;
- }
- /**
- * Retrieves the base decorative structure.
- *
- * @return Decorative Base decorative.
- */
- public function get_decorative(){
- return $this->decorative;
- }
- /**
- * Retrieves the decoration level.
- *
- * @return int Decoration level.
- */
- public function get_level(){
- return $this->level;
- }
- }
|