Effect.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Effect entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::ENTITY . "Entity.php");
  12. /**
  13. * Skill effect.
  14. *
  15. * Represents an effect a skill can induce.
  16. *
  17. * @category Entity
  18. */
  19. class Effect extends Entity{
  20. /**
  21. * @var int Effect ID.
  22. */
  23. private $id;
  24. /**
  25. * @var string Effect name.
  26. */
  27. private $name;
  28. /**
  29. * @var bool Indicates if the effect is a buff.
  30. */
  31. private $is_buff;
  32. /**
  33. * @var string Effect description.
  34. */
  35. private $description;
  36. /**
  37. * Constructor.
  38. *
  39. * Searches the database and retrieves the information about the
  40. * skill level, populating it and it's items.
  41. *
  42. * @param int $id Effect identifier.
  43. */
  44. public function __construct($id){
  45. $statement = get_context()->get_db()->prepare("
  46. SELECT
  47. id,
  48. name,
  49. is_buff,
  50. description
  51. FROM effect
  52. WHERE id = :id;
  53. ");
  54. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  55. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  56. if ($r){
  57. $this->id = $r["id"];
  58. $this->name = HTML::e($r["name"]);
  59. $this->is_buff = $r["is_buff"];
  60. $this->description = HTML::e($r["description"]);
  61. }
  62. }
  63. /**
  64. * Retrieves the effect identifier.
  65. *
  66. * @return int Effect ID.
  67. */
  68. public function get_id(){
  69. return $this->id;
  70. }
  71. /**
  72. * Retrieves the effect name.
  73. *
  74. * @return string Effect name.
  75. */
  76. public function get_name(){
  77. return $this->name;
  78. }
  79. /**
  80. * Checks if the effect is a a buff (a good effect).
  81. *
  82. * @return bool True if buff, false if not.
  83. */
  84. public function is_buff(){
  85. return $this->is_buff;
  86. }
  87. /**
  88. * Checks if the efect is a a debuff (a bad effect).
  89. *
  90. * @return bool True if buff, false if not.
  91. */
  92. public function is_debuff(){
  93. return ! $this->is_buff;
  94. }
  95. /**
  96. * Retrieves the effect description.
  97. *
  98. * @return string Effect description.
  99. */
  100. public function get_description(){
  101. return $this->description;
  102. }
  103. /**
  104. * Gets the pathto the monster image.
  105. * @return string Image URL, or a fixed unknown image.
  106. */
  107. public function get_image(){
  108. return APPLICATION::img("EFFECT", $this->id);
  109. }
  110. }