| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- <?php
- require_once($path["entity"] . "Entity.php");
- require_once($path["entity"] . "K_Monster.php");
- require_once($path["entity"] . "Rune.php");
- /**
- * Monster.
- *
- * Represents an object from the table 'monster'.
- */
- class Monster extends Entity{
- /**
- * Monster identifier.
- */
- public $id;
- /**
- * Monster official identifier.
- */
- public $com2us_id;
- /**
- * {@see K_Monster}.
- */
- public $monster;
- /**
- * Monster stars.
- */
- public $stars;
- /**
- * Monster level.
- */
- public $level;
- /**
- * Level of skill 1
- */
- public $skill_1_level;
- /**
- * Level of skill 2
- */
- public $skill_2_level;
- /**
- * Level of skill 3
- */
- public $skill_3_level;
- /**
- * Level of skill 4
- */
- public $skill_4_level;
- /**
- * Monster base HP stat.
- */
- public $base_hp;
- /**
- * Monster base ATK stat.
- */
- public $base_attack;
- /**
- * Monster base DEF stat.
- */
- public $base_defense;
- /**
- * Monster base SPD stat.
- */
- public $base_speed;
- /**
- * Monster base CRR stat.
- */
- public $base_crit_rate;
- /**
- * Monster base CRD stat.
- */
- public $base_crit_damage;
- /**
- * Monster base RES stat.
- */
- public $base_resistance;
- /**
- * Monster base ACC stat.
- */
- public $base_accuracy;
- /**
- * Monster rune HP stat.
- */
- public $rune_hp;
- /**
- * Monster rune ATK stat.
- */
- public $rune_attack;
- /**
- * Monster rune DEF stat.
- */
- public $rune_defense;
- /**
- * Monster rune SPD stat.
- */
- public $rune_speed;
- /**
- * Monster rune CRR stat.
- */
- public $rune_crit_rate;
- /**
- * Monster rune CRD stat.
- */
- public $rune_crit_damage;
- /**
- * Monster rune RES stat.
- */
- public $rune_resistance;
- /**
- * Monster rune ACC stat.
- */
- public $rune_accuracy;
- /**
- * Average rune efficiency.
- */
- public $avg_rune_efficiency;
- /**
- * Indicates if the monster is fodder.
- */
- public $fodder;
- /**
- * Indicates if the monster is in storage.
- */
- public $in_storage;
- /**
- * Indicates if the monster is ignored in fusion calc.
- */
- public $ignore_for_fusion;
- /**
- * Monster priority.
- */
- public $priority;
- /**
- * Notes on the monster.
- */
- public $notes;
- /**
- * Equiped {@see Rune}s
- */
- public $rune = [];
- /**
- * 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, " .
- " monster, " .
- " stars, " .
- " level, " .
- " skill_1_level, " .
- " skill_2_level, " .
- " skill_3_level, " .
- " skill_4_level, " .
- " base_hp, " .
- " base_attack, " .
- " base_defense, " .
- " base_speed, " .
- " base_crit_rate, " .
- " base_crit_damage, " .
- " base_resistance, " .
- " base_accuracy, " .
- " rune_hp, " .
- " rune_attack, " .
- " rune_defense, " .
- " rune_speed, " .
- " rune_crit_rate, " .
- " rune_crit_damage, " .
- " rune_resistance, " .
- " rune_accuracy, " .
- " avg_rune_efficiency, " .
- " fodder, " .
- " in_storage, " .
- " ignore_for_fusion, " .
- " priority, " .
- " notes " .
- "FROM monster " .
- "WHERE id = '$id'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->id = $r["id"];
- $this->com2us_id = $r["com2us_id"];
- if (strlen($r["monster"]) > 0){
- $this->monster = new K_Monster($this->db, $r["monster"]);
- }
- $this->stars = $r["stars"];
- $this->level = $r["level"];
- $this->skill_1_level = $r["skill_1_level"];
- $this->skill_2_level = $r["skill_2_level"];
- $this->skill_3_level = $r["skill_3_level"];
- $this->skill_4_level = $r["skill_4_level"];
- $this->base_hp = $r["base_hp"];
- $this->base_attack = $r["base_attack"];
- $this->base_defense = $r["base_defense"];
- $this->base_speed = $r["base_speed"];
- $this->base_crit_rate = $r["base_crit_rate"];
- $this->base_crit_damage = $r["base_crit_damage"];
- $this->base_resistance = $r["base_resistance"];
- $this->base_accuracy = $r["base_accuracy"];
- $this->rune_hp = $r["rune_hp"];
- $this->rune_attack = $r["rune_attack"];
- $this->rune_defense = $r["rune_defense"];
- $this->rune_speed = $r["rune_speed"];
- $this->rune_crit_rate = $r["rune_crit_rate"];
- $this->rune_crit_damage = $r["rune_crit_damage"];
- $this->rune_resistance = $r["rune_resistance"];
- $this->rune_accuracy = $r["rune_accuracy"];
- $this->avg_rune_efficiency = $r["avg_rune_efficiency"];
- $this->fodder = $r["fodder"];
- $this->in_storage = $r["in_storage"];
- $this->ignore_for_fusion = $r["ignore_for_fusion"];
- $this->priority = $r["priority"];
- $this->notes = $r["notes"];
- $s =
- "SELECT rune " .
- "FROM monster_rune " .
- "WHERE monster = '$this->id'; ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->rune, new Rune($this->db, $r["rune"]));
- }
- }
- /**
- * TODO: UNUSED
- * Gets a stat increase from rune monsters.
- *
- * @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_rune_stat($stat){
- switch ($stat){
- case "ATK":
- $base = $this->atk;
- $name_flat = 'ATK flat';
- $name_perc = 'ATK%';
- break;
- case "DEF":
- $base = $this->def;
- $name_flat = 'DEF flat';
- $name_perc = 'DEF%';
- break;
- case "HP":
- $base = $this->hp;
- $name_flat = 'HP flat';
- $name_perc = 'HP%';
- break;
- case "SPD":
- $base = $this->hp;
- $name_flat = 'SPD';
- $name_perc = '-';
- break;
- case "CRR":
- $base = $this->crr;
- $name_flat = 'CRate';
- $name_perc = '-';
- break;
- case "CRD":
- $base = $this->crd;
- $name_flat = 'CDmg';
- $name_perc = '-';
- break;
- case "RES":
- $base = $this->res;
- $name_flat = 'RES';
- $name_perc = '-';
- break;
- case "ACC":
- $base = $this->acc;
- $name_flat = 'ACC';
- $name_perc = '-';
- break;
- default:
- return -1;
- }
- $s =
- "SELECT sum(value) AS v FROM ( " .
- " SELECT m_v AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND m_t = '" . $name_flat . "' " .
- " UNION " .
- " SELECT cast(m_v * " . $base . " / 100 AS int) AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND m_t = '" . $name_perc . "' " .
- " UNION " .
- " SELECT i_v AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND i_t = '" . $name_flat . "' " .
- " UNION " .
- " SELECT cast(i_v * " . $base . " / 100 AS int) AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND i_t = '" . $name_perc . "' " .
- " UNION " .
- " SELECT s1_v AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s1_t = '" . $name_flat . "' " .
- " UNION " .
- " SELECT cast(s1_v * " . $base . " / 100 AS int) AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s1_t = '" . $name_perc . "' " .
- " UNION " .
- " SELECT s2_v AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s2_t = '" . $name_flat . "' " .
- " UNION " .
- " SELECT cast(s2_v * " . $base . " / 100 AS int) AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s2_t = '" . $name_perc . "' " .
- " UNION " .
- " SELECT s3_v AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s3_t = '" . $name_flat . "' " .
- " UNION " .
- " SELECT cast(s3_v * " . $base . " / 100 AS int) AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s3_t = '" . $name_perc . "' " .
- " UNION " .
- " SELECT s4_v AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s4_t = '" . $name_flat . "' " .
- " UNION " .
- " SELECT cast(s4_v * " . $base . " / 100 AS int) AS value FROM rune, monster_rune WHERE rune = id AND monster = " . $this->id . " AND s4_t = '" . $name_perc . "' " .
- ");";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- return $r["v"];
- }
- }
- ?>
|