Monster.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "K_Monster.php");
  4. require_once($path["entity"] . "Rune.php");
  5. /**
  6. * Monster.
  7. *
  8. * Represents an object from the table 'monster'.
  9. */
  10. class Monster extends Entity{
  11. /**
  12. * Monster identifier.
  13. */
  14. public $id;
  15. /**
  16. * Monster official identifier.
  17. */
  18. public $com2us_id;
  19. /**
  20. * {@see K_Monster}.
  21. */
  22. public $monster;
  23. /**
  24. * Monster stars.
  25. */
  26. public $stars;
  27. /**
  28. * Monster level.
  29. */
  30. public $level;
  31. /**
  32. * Level of skill 1
  33. */
  34. public $skill_1_level;
  35. /**
  36. * Level of skill 2
  37. */
  38. public $skill_2_level;
  39. /**
  40. * Level of skill 3
  41. */
  42. public $skill_3_level;
  43. /**
  44. * Level of skill 4
  45. */
  46. public $skill_4_level;
  47. /**
  48. * Monster base HP stat.
  49. */
  50. public $base_hp;
  51. /**
  52. * Monster base ATK stat.
  53. */
  54. public $base_attack;
  55. /**
  56. * Monster base DEF stat.
  57. */
  58. public $base_defense;
  59. /**
  60. * Monster base SPD stat.
  61. */
  62. public $base_speed;
  63. /**
  64. * Monster base CRR stat.
  65. */
  66. public $base_crit_rate;
  67. /**
  68. * Monster base CRD stat.
  69. */
  70. public $base_crit_damage;
  71. /**
  72. * Monster base RES stat.
  73. */
  74. public $base_resistance;
  75. /**
  76. * Monster base ACC stat.
  77. */
  78. public $base_accuracy;
  79. /**
  80. * Monster rune HP stat.
  81. */
  82. public $rune_hp;
  83. /**
  84. * Monster rune ATK stat.
  85. */
  86. public $rune_attack;
  87. /**
  88. * Monster rune DEF stat.
  89. */
  90. public $rune_defense;
  91. /**
  92. * Monster rune SPD stat.
  93. */
  94. public $rune_speed;
  95. /**
  96. * Monster rune CRR stat.
  97. */
  98. public $rune_crit_rate;
  99. /**
  100. * Monster rune CRD stat.
  101. */
  102. public $rune_crit_damage;
  103. /**
  104. * Monster rune RES stat.
  105. */
  106. public $rune_resistance;
  107. /**
  108. * Monster rune ACC stat.
  109. */
  110. public $rune_accuracy;
  111. /**
  112. * Average rune efficiency.
  113. */
  114. public $avg_rune_efficiency;
  115. /**
  116. * Indicates if the monster is fodder.
  117. */
  118. public $fodder;
  119. /**
  120. * Indicates if the monster is in storage.
  121. */
  122. public $in_storage;
  123. /**
  124. * Indicates if the monster is ignored in fusion calc.
  125. */
  126. public $ignore_for_fusion;
  127. /**
  128. * Monster priority.
  129. */
  130. public $priority;
  131. /**
  132. * Notes on the monster.
  133. */
  134. public $notes;
  135. /**
  136. * Equiped {@see Rune}s
  137. */
  138. public $rune = [];
  139. /**
  140. * Constructor.
  141. *
  142. * Searches the database and retrieves the information about the
  143. * monster, populating it and it's items.
  144. *
  145. * @param SQLite3 $db Connection to the database.
  146. * @param int $id Monster identifier.
  147. * @param complete If false, query only monster and k_monster.
  148. */
  149. public function __construct($db, $id, $complete = true){
  150. global $path;
  151. parent::__construct($db);
  152. $s =
  153. "SELECT " .
  154. " id, " .
  155. " com2us_id, " .
  156. " monster, " .
  157. " stars, " .
  158. " level, " .
  159. " skill_1_level, " .
  160. " skill_2_level, " .
  161. " skill_3_level, " .
  162. " skill_4_level, " .
  163. " base_hp, " .
  164. " base_attack, " .
  165. " base_defense, " .
  166. " base_speed, " .
  167. " base_crit_rate, " .
  168. " base_crit_damage, " .
  169. " base_resistance, " .
  170. " base_accuracy, " .
  171. " rune_hp, " .
  172. " rune_attack, " .
  173. " rune_defense, " .
  174. " rune_speed, " .
  175. " rune_crit_rate, " .
  176. " rune_crit_damage, " .
  177. " rune_resistance, " .
  178. " rune_accuracy, " .
  179. " avg_rune_efficiency, " .
  180. " fodder, " .
  181. " in_storage, " .
  182. " ignore_for_fusion, " .
  183. " priority, " .
  184. " notes " .
  185. "FROM monster " .
  186. "WHERE id = '$id'; ";
  187. $q = $this->db->query($s);
  188. $r = $q->fetchArray(SQLITE3_ASSOC);
  189. $this->id = $r["id"];
  190. $this->com2us_id = $r["com2us_id"];
  191. if (strlen($r["monster"]) > 0){
  192. $this->monster = new K_Monster($this->db, $r["monster"], $complete);
  193. }
  194. $this->stars = $r["stars"];
  195. $this->level = $r["level"];
  196. $this->skill_1_level = $r["skill_1_level"];
  197. $this->skill_2_level = $r["skill_2_level"];
  198. $this->skill_3_level = $r["skill_3_level"];
  199. $this->skill_4_level = $r["skill_4_level"];
  200. $this->base_hp = $r["base_hp"];
  201. $this->base_attack = $r["base_attack"];
  202. $this->base_defense = $r["base_defense"];
  203. $this->base_speed = $r["base_speed"];
  204. $this->base_crit_rate = $r["base_crit_rate"];
  205. $this->base_crit_damage = $r["base_crit_damage"];
  206. $this->base_resistance = $r["base_resistance"];
  207. $this->base_accuracy = $r["base_accuracy"];
  208. $this->rune_hp = $r["rune_hp"];
  209. $this->rune_attack = $r["rune_attack"];
  210. $this->rune_defense = $r["rune_defense"];
  211. $this->rune_speed = $r["rune_speed"];
  212. $this->rune_crit_rate = $r["rune_crit_rate"];
  213. $this->rune_crit_damage = $r["rune_crit_damage"];
  214. $this->rune_resistance = $r["rune_resistance"];
  215. $this->rune_accuracy = $r["rune_accuracy"];
  216. $this->avg_rune_efficiency = $r["avg_rune_efficiency"];
  217. $this->fodder = $r["fodder"];
  218. $this->in_storage = $r["in_storage"];
  219. $this->ignore_for_fusion = $r["ignore_for_fusion"];
  220. $this->priority = $r["priority"];
  221. $this->notes = $r["notes"];
  222. if ($complete){
  223. $this->load_runes();
  224. }
  225. }
  226. /**
  227. * Loads the information about the equiped runes.
  228. * It is autoatically called at construction time if the
  229. * $complete parameter is true (by default). No point in calling it
  230. * twice.
  231. */
  232. public function load_runes(){
  233. $this->rune = [];
  234. $s =
  235. "SELECT rune " .
  236. "FROM monster_rune " .
  237. "WHERE monster = '$this->id'; ";
  238. $q = $this->db->query($s);
  239. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  240. array_push($this->rune, new Rune($this->db, $r["rune"]));
  241. }
  242. }
  243. }
  244. ?>