id; } /** * Retrieves the name of the skill_group. * * @return string Group name. */ public function get_name(){ return $this->name; } /** * Retrieves the description of the skill group. * * @return string Group description. */ public function get_description(){ return $this->description; } /** * Retrieves the skills in the group. * * @return Guild_Skill[] Skills in the group. */ public function get_skills(){ if (! $this->flag_skills){ $this->load_skills(); } return $this->skills; } /** * Constructor. * * Searches the database and retrieves the information about the * skill group, populating it and it's items. * * @param int $id Skill group identifier. */ public function __construct($id){ $statement = get_context()->get_db()->prepare(" SELECT id, name, description FROM guild_skill_group 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"]); } } private function load_skills(){ $statement = get_context()->get_db()->prepare(" SELECT id FROM guild_skill WHERE skill_group = :id; "); $statement->bindValue(':id', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->skills, new Guild_Skill($r["id"])); } $this->flag_skills = true; } /** * Gets the pathto the monster image. The image must be in the * img/skill_guild/ directory, and its name must be the monster id, * padded with '0' to 1 digits, and the extension must be '.png'. * * @return string Image URL, or a fixed unknown image. */ public function get_image(){ return APPLICATION::img("SKILL_GUILD", $this->id); } } ?>