Monster_Skill.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Monster.
  5. *
  6. * Represents an object from the table 'monster'.
  7. */
  8. class Monster_Skill extends Entity{
  9. /**
  10. * Skill identifier.
  11. */
  12. public $id;
  13. /**
  14. * Skill order.
  15. */
  16. public $idx;
  17. /**
  18. * Skill name.
  19. */
  20. public $name;
  21. /**
  22. * Skill description.
  23. */
  24. public $desc;
  25. /**
  26. * Wether the skill is passive or not.
  27. */
  28. public $pasive;
  29. /**
  30. * Base monster. {@see Monster_Base}
  31. */
  32. public $awaken;
  33. /**
  34. * Wether the skill is a leader one.
  35. */
  36. public $leader;
  37. /**
  38. * Skill image.
  39. */
  40. public $img;
  41. /**
  42. * The {@see Monster_Skill} upgrading this one.
  43. */
  44. public $upgrade;
  45. /**
  46. * Constructor.
  47. *
  48. * Searches the database and retrieves the information about the
  49. * skill, populating it and it's items.
  50. *
  51. * @param SQLite3 $db Connection to the database.
  52. * @param int $id Monster identifier.
  53. */
  54. public function __construct($db, $id){
  55. global $path;
  56. parent::__construct($db);
  57. $s =
  58. "SELECT " .
  59. " id, " .
  60. " idx, " .
  61. " name, " .
  62. " desc, " .
  63. " passive, " .
  64. " upgrade, " .
  65. " awaken, " .
  66. " leader, " .
  67. " img, " .
  68. " cooldown " .
  69. "FROM monster_skill " .
  70. "WHERE id = $id; ";
  71. $q = $this->db->query($s);
  72. $r = $q->fetchArray(SQLITE3_ASSOC);
  73. if ($r){
  74. $this->id = $r["id"];
  75. $this->idx = $r["idx"];
  76. $this->name = $r["name"];
  77. $this->desc = $r["desc"];
  78. $this->passive = $r["passive"];
  79. $this->awaken = $r["awaken"];
  80. $this->leader = $r["leader"];
  81. $this->img = $path["img"]["skill"] . $r["img"];
  82. $this->cooldown = $r["cooldown"];
  83. if ($r["upgrade"] != 0){
  84. error_log("UPGRADE: " . $this->id . " -> " . $r["upgrade"]);
  85. $this->upgrade = new Monster_Skill($this->db, $r["upgrade"]);
  86. }
  87. }
  88. }
  89. }
  90. ?>