"", * "grade" => "", * "amount" => * ] */ public $essences = []; /** * {@see K_Source}s the monster can be get from. */ public $sources = []; /** * Constructor. * * Searches the database and retrieves the information about the * monster, populating it and it's items. * * @param SQLite3 $db Connection to the database. * @param int $id Monster identifier. */ public function __construct($db, $id){ global $path; parent::__construct($db); $s = "SELECT " . " id, " . " com2us_id, " . " family_id, " . " name, " . " element, " . " archetype, " . " base_stars, " . " natural_stars, " . " obtainable, " . " can_awaken, " . " awaken_bonus, " . " skill_ups_to_max, " . " leader_skill, " . " base_hp, " . " base_attack, " . " base_defense, " . " speed, " . " crit_rate, " . " crit_damage, " . " resistance, " . " accuracy, " . " raw_hp, " . " raw_attack, " . " raw_defense, " . " max_lvl_hp, " . " max_lvl_attack, " . " max_lvl_defense, " . " awakens_from, " . " awakens_to, " . " fusion_food, " . " homunculus, " . " craft_cost " . "FROM k_monster " . "WHERE id = $id; "; $q = $this->db->query($s); $r = $q->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["id"]; $this->com2us_id = $r["com2us_id"]; $this->family_id = $r["family_id"]; $this->name = $r["name"]; $this->element = $r["element"]; $this->archetype = $r["archetype"]; $this->base_stars = $r["base_stars"]; $this->natural_stars = $r["natural_stars"]; $this->obtainable = $r["obtainable"]; $this->can_awaken = $r["can_awaken"]; $this->awaken_bonus = $r["awaken_bonus"]; $this->skill_ups_to_max = $r["skill_ups_to_max"]; if ($r["leader_skill"]){ $this->leader_skill = new K_Leader_Skill($this->db, $r["leader_skill"]); } $this->base_hp = $r["base_hp"]; $this->base_attack = $r["base_attack"]; $this->base_defense = $r["base_defense"]; $this->speed = $r["speed"]; $this->crit_rate = $r["crit_rate"]; $this->crit_damage = $r["crit_damage"]; $this->resistance = $r["resistance"]; $this->accuracy = $r["accuracy"]; $this->raw_hp = $r["raw_hp"]; $this->raw_attack = $r["raw_attack"]; $this->raw_defense = $r["raw_defense"]; $this->max_lvl_hp = $r["max_lvl_hp"]; $this->max_lvl_attack = $r["max_lvl_attack"]; $this->max_lvl_defense = $r["max_lvl_defense"]; $this->awakens_from = $r["awakens_from"]; $this->awakens_to = $r["awakens_to"]; $this->fusion_food = $r["fusion_food"]; $this->homunculus = $r["homunculus"]; $this->craft_cost = $r["craft_cost"]; } $s = "SELECT " . " skill " . "FROM " . " k_skill, " . " k_monster_skill " . "WHERE " . " id = skill AND " . " monster = $id " . "ORDER BY slot; "; $q = $this->db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->skill, new K_Skill($this->db, $r["skill"])); } $s = "SELECT " . " element, " . " grade, " . " amount " . "FROM k_monster_essence " . "WHERE " . " monster = $id " . "ORDER BY " . " element <> 'Magic', " . " grade <> 'Low', " . " grade <> 'Mid'; "; $q = $this->db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ $e = [ "element" => $r["element"], "grade" => $r["grade"], "amount" => $r["amount"] ]; array_push($this->essences, $e); } $s = "SELECT source " . "FROM k_monster_source " . "WHERE monster = $id; "; $q = $this->db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->sources, new K_Source($this->db, $r["source"])); } } /** * Gets the pathto the monster image. The image must be in the * img/content/monster/ directory, and its name must be the monster id, * padded with '0' to 4 digites, and the extension must be '.png'. * * @return path to the image, or a path to a fixed unknown image if it * doesn't exist. */ public function get_image(){ global $base_dir; global $path; if (file_exists($base_dir . "img/content/monster/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){ return $path["img"]["content"] . "monster/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png"; } else{ return $path["img"]["layout"] . "unknown.png"; } } } ?>