| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- /**
- * Decoration key entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Decoration.
- *
- * Represents an object from the table 'k_decoration'.
- *
- * @category Entity
- */
- class K_Decoration extends Entity{
- /**
- * @var int Decoration identifier.
- */
- public $id;
- /**
- * @var string Decoration name.
- */
- public $name;
- /**
- * @var string Decoration description.
- */
- public $description;
- /**
- * @var int Area of effect identifier (if any).
- */
- public $area;
- /**
- * @var int Affected stat id (if any).
- */
- public $stat;
- /**
- * @var int Affected element id(if any).
- */
- public $element;
- /**
- * @var int Max. level.
- */
- public $max_level;
- /**
- * @var int[] Effect bonus per level.
- */
- public $level_bonus = [];
- /**
- * Cost per level.
- */
- public $level_cost = [];
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * decoration, populating it and it's items.
- *
- * @param int $id Decoration identifier.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $statement = $db->prepare("
- SELECT
- id,
- name,
- description,
- area,
- affected_stat,
- element,
- max_level
- FROM k_decoration
- 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->area = $r["area"];
- $this->stat = $r["affected_stat"];
- $this->element = $r["element"];
- $this->max_level = $r["max_level"];
- $statement = $db->prepare("
- SELECT
- level,
- bonus,
- cost
- FROM k_decoration_level
- WHERE decoration = :id
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $q = $statement->execute();
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- $this->level_bonus[$r["level"]] = $r["bonus"];
- $this->level_cost[$r["level"]] = $r["cost"];
- }
- }
- }
- /**
- * Gets the path to the building image. The image must be in the
- * img/decoration/ directory, and its name must be the decoration
- * 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("DECORATION", $this->id);
- }
- }
- ?>
|