Effect.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Effect key entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @category Entity
  8. */
  9. /**
  10. * Require dependent entities if not present.
  11. */
  12. require_once(PATH::ENTITY . "Entity.php");
  13. /**
  14. * Skill effect.
  15. *
  16. * Represents an object from the table 'effect'.
  17. *
  18. * @category Entity
  19. */
  20. class Effect extends Entity{
  21. private $id;
  22. private $name;
  23. private $is_buff;
  24. private $description;
  25. /**
  26. * Constructor.
  27. *
  28. * Searches the database and retrieves the information about the
  29. * skill level, populating it and it's items.
  30. *
  31. * @param int $id Effect identifier.
  32. */
  33. public function __construct($id){
  34. $statement = get_context()->get_db()->prepare("
  35. SELECT
  36. id,
  37. name,
  38. is_buff,
  39. description
  40. FROM effect
  41. WHERE id = :id;
  42. ");
  43. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  44. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  45. if ($r){
  46. $this->id = $r["id"];
  47. $this->name = HTML::e($r["name"]);
  48. $this->is_buff = $r["is_buff"];
  49. $this->description = HTML::e($r["description"]);
  50. }
  51. }
  52. /**
  53. * Retrieves the effect identifier.
  54. *
  55. * @return int Effect ID.
  56. */
  57. public function get_id(){
  58. return $this->id;
  59. }
  60. /**
  61. * Retrieves the effect name.
  62. *
  63. * @return string Effect name.
  64. */
  65. public function get_name(){
  66. return $this->name;
  67. }
  68. /**
  69. * Checks if the efect is a a buff
  70. *
  71. * @return boolean
  72. */
  73. public function is_buff(){
  74. return $this->is_buff;
  75. }
  76. /**
  77. * Checks if the efect is a a debuff
  78. *
  79. * @return boolean
  80. */
  81. public function is_debuff(){
  82. return ! $this->is_buff;
  83. }
  84. /**
  85. * Retrieves the effect description.
  86. *
  87. * @return string Effect description.
  88. */
  89. public function get_description(){
  90. return $this->description;
  91. }
  92. /**
  93. * Gets the pathto the monster image.
  94. * @return string Image URL, or a fixed unknown image.
  95. */
  96. public function get_image(){
  97. return APPLICATION::img("EFFECT", $this->id);
  98. }
  99. }
  100. ?>