| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <?php
- require_once($path["entity"] . "Entity.php");
- require_once($path["entity"] . "K_Skill.php");
- require_once($path["entity"] . "K_Leader_Skill.php");
- /**
- * Monster.
- *
- * Represents an object from the table 'monster'.
- */
- class K_Monster extends Entity{
- /**
- * Monster identifier.
- */
- public $id;
- /**
- * Monster official identifier.
- */
- public $com2us_id;
- /**
- * Monster family id.
- */
- public $family_id;
- /**
- * Monster name.
- */
- public $name;
- /**
- * Monster element.
- */
- public $element;
- /**
- * Monster archetype.
- */
- public $archetype;
- /**
- * Default star level.
- */
- public $base_stars;
- /**
- * Default star level.
- */
- public $natural_stars;
-
- /**
- * Indicates if the monster is obtainable.
- */
- public $obtainable;
- /**
- * Indicates if the monster can be awakened.
- */
- public $can_awaken;
- /**
- * Bonus when awakening.
- */
- public $awaken_bonus;
- /**
- * Required skill-ups.
- */
- public $skill_ups_to_max;
- /**
- * @{see K_Leader_Skill} of the monster.
- */
- public $leader_skill;
- /**
- * Base HP.
- */
- public $base_hp;
- /**
- * Base ATK.
- */
- public $base_atk;
- /**
- * Base DEF.
- */
- public $base_defense;
- /**
- * SPD.
- */
- public $speed;
- /**
- * CRR.
- */
- public $crit_rate;
- /**
- * CRD.
- */
- public $crit_damage;
- /**
- * RES
- */
- public $resistance;
- /**
- * ACC.
- */
- public $accuracy;
- /**
- * Raw HP.
- */
- public $raw_hp;
- /**
- * Raw ATK.
- */
- public $raw_atk;
- /**
- * Raw DEF.
- */
- public $raw_defense;
- /**
- * HP at max_level.
- */
- public $max_lvl_hp;
- /**
- * ATK at max_level.
- */
- public $max_lvl_atk;
- /**
- * DEF at max_level.
- */
- public $max_lvl_defense;
- /**
- * @{see Monster} it awakens from.
- */
- public $awakens_from;
- /**
- * @{see Monster} it awakens to.
- */
- public $awakens_to;
- /**
- * Indicates if the monster is a fusion ingredient.
- */
- public $fusion_food;
- /**
- * Indicates if the monster is homunculus.
- */
- public $homunculus;
- /**
- * The crafting cost (homunculus only).
- */
- public $craft_cost;
- /**
- * All {@see K_Monster_Skill}s.
- */
- public $skill = [];
- /**
- * 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"];
- /*if ($r["awakens_from"]){
- $this->awakens_from = new K_Monster($this->db, $r["awakens_from"]);
- }
- if ($r["awakens_to"]){
- $this->awakens_to = new K_Monster($this->db, $r["awakens_to"]);
- }*/
- $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"]));
- }
- }
-
- 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";
- }
- }
- /**
- * TODO: UNUSED
- *
- * @param $stat Stat name ("ATK", "DEF", "HP", "SPD", "CRR", "CRD", "RES", "ACC").
- * @return Value of the base stat (floored integer), -1 if wrong stat.
- */
- public function get_base_stat($stat){
- if ($stat == "ATK" || $stat == "DEF" || $stat == "HP" || $stat == "SPD" || $stat == "CRR" || $stat == "CRD" || $stat == "RES" || $stat == "ACC"){
- $s =
- "SELECT " .
- " min, " .
- " max " .
- "FROM k_monster_stat " .
- "WHERE " .
- " monster = " . $this->k_monster->id . " AND " .
- " stat = '" . $stat . "' AND " .
- " stars = " . $this->stars . " AND " .
- " awake = " . $this->awakened . ";";
- $q = $this->db->query($s);
- if ($q){
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $min = $r["min"];
- $max = $r["max"];
- $min_level = 1;
- $max_level = 40;
- switch ($this->stars){
- case 1:
- $max_level = 15;
- break;
- case 2:
- $max_level = 20;
- break;
- case 3:
- $max_level = 25;
- break;
- case 4:
- $max_level = 30;
- break;
- case 5:
- $max_level = 35;
- break;
- }
- $base = $min + (($max - $min) * $this->level / $max_level);
- return floor($base);
- }
- else{
- return -1;
- }
- }
- else{
- return -1;
- }
- }
- else{
- return -1;
- }
- }
- }
- ?>
|