get_db()->prepare(" SELECT id, name, description, slot, cooltime, hits, passive, aoe, max_level, multiplier_formula FROM skill 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->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"]); } } private function load_levels(){ $statement = get_context()->get_db()->prepare(" SELECT skill, level FROM skill_level WHERE skill = :skill ORDER BY level; "); $statement->bindValue(':skill', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->level, new Skill_Level($r["skill"], $r["level"])); } $this->flag_levels = true; } private function load_effects(){ $statement = get_context()->get_db()->prepare(" SELECT DISTINCT effect FROM skill_effect WHERE skill = :skill; "); $statement->bindValue(':skill', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->effect, new Effect($r["effect"])); } $this->flag_effects = true; } /** * Retrieves the skill identifier. * * @return number Skill id. */ public function get_id(){ return $this->id; } /** * Retrieves the skill name. * * @return string Sill name. */ public function get_name(){ return $this->name; } /** * Retrieves the skill description. * * @return string Skill description. */ public function get_description(){ return $this->description; } /** * Retrieves the skill slot. * * @return number The skill slot (1-4); */ public function get_slot(){ return $this->slot; } /** * Retrieves the skill cooldown time * * @return number Skill cooltime. */ public function get_cooltime(){ return $this->cooltime; } /** * Retrieves the number of times the skill hist. * * @return number Number of hits. */ public function get_hits(){ return $this->hits; } /** * Checks if the skill is passive. * * @return boolean True for passive skills, false for active. */ public function is_passive(){ return $this->passive; } /** * Checks if the skills affects a group instead of a unit. * * @return boolean True for AOE skills, false for single-target skills. */ public function is_aoe(){ return $this->aoe; } /** * Retrieves the maximum level of the skill. * * @return number Skill max level. */ public function get_max_level(){ return $this->max_level; } /** * Retrieves the skills mathematical formula. * * @return string Skill formula. */ public function get_multiplier_formula(){ return $this->multiplier_formula; } /** * Retrieves the skill this one upgrades to (ie, on awakening). * * @return Skill Upgraded skill, null if not upgradeable. */ public function get_upgrade(){ return $this->upgrade; } /** * Retrieves information about the skill levels. * * @return Skill_Level[] Levels of the skill. */ public function get_levels(){ if (! $this->flag_levels){ $this->load_levels(); } return $this->level; } /** * Retrieves the effects caused by the skill. * * @return Effect[] Effects caused by the skill. */ public function get_effects(){ if (! $this->flag_effects){ $this->load_effects(); } return $this->effect; } /** * Gets the path to the skill image. * * @return string Image URL, or a fixed unknown image. */ public function get_image(){ return APPLICATION::img("SKILL", $this->id); } } ?>