| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- /**
- * Skill 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 . "K_Skill_Level.php");
- require_once(PATH::ENTITY . "K_Effect.php");
- /**
- * Monster skill.
- *
- * Represents an object from the table 'k_skill'.
- *
- * @category Entity
- */
- class K_Skill extends Entity{
- /**
- * @var int Skill identifier.
- */
- public $id;
- /**
- * @var string Skill name.
- */
- public $name;
- /**
- * @var string Skill description.
- */
- public $description;
- /**
- * @var int Skill order.
- */
- public $slot;
- /**
- * @var int Skill cooldown turns.
- */
- public $cooltime;
- /**
- * @var int Number of hits.
- */
- public $hits;
- /**
- * @var bool Wether the skill is passive or not.
- */
- public $passive;
- /**
- * @var bool Wether the skill is AOE.
- */
- public $aoe;
- /**
- * @var int Skill max level.
- */
- public $max_level;
- /**
- * @var string Skill formula.
- */
- public $multiplier_formula;
- /**
- * @var K_SKill The skill upgrading this one.
- */
- public $upgrade;
- /**
- * @var \K_Skill_Level[] Available skill levels.
- */
- public $level = [];
- /**
- * @var \K_Effect[] Associated eeffects.
- */
- public $effect = [];
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * skill, populating it and it's items.
- *
- * @param int $id Skill identifier.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $statement = $db->prepare("
- SELECT
- id,
- name,
- description,
- slot,
- cooltime,
- hits,
- passive,
- aoe,
- max_level,
- multiplier_formula
- FROM k_skill
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_INTEGER);
- $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->slot = $r["slot"];
- $this->cooltime = $r["cooltime"];
- $this->hits = $r["hits"];
- $this->passive = $r["passive"];
- $this->aoe = $r["aoe"];
- $this->max_level = $r["max_level"];
- $this->multiplier_formula = HTML::e($r["multiplier_formula"]);
- $statement = $db->prepare("
- SELECT
- skill,
- level
- FROM k_skill_level
- WHERE skill = :skill
- ORDER BY level;
- ");
- $statement->bindValue(':skill', $this->id, SQLITE3_INTEGER);
- $q = $statement->execute();
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->level, new K_Skill_Level($r["skill"], $r["level"]));
- }
- $statement = $db->prepare("
- SELECT DISTINCT effect
- FROM k_skill_effect
- WHERE skill = :skill;
- ");
- $statement->bindValue(':skill', $this->id, SQLITE3_INTEGER);
- $q = $statement->execute();
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->effect, new K_Effect($r["effect"]));
- }
- }
- }
- /**
- * Gets the path to the skill image. The image must be in the
- * img/skill/ directory, and its name must be the set id,
- * padded with '0' to 8 digits, and the extension must be '.png'.
- *
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image(){
- return APPLICATION::img("SKILL", $this->id);
- }
- }
- ?>
|