Effect.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /**
  22. * @var int Effect identifier.
  23. */
  24. public $id;
  25. /**
  26. * @var string Effect name.
  27. */
  28. public $name;
  29. /**
  30. * @var bool Indicates if the effect is a buff.
  31. */
  32. public $is_buff;
  33. /**
  34. * @var string Effect description.
  35. */
  36. public $description;
  37. /**
  38. * Constructor.
  39. *
  40. * Searches the database and retrieves the information about the
  41. * skill level, populating it and it's items.
  42. *
  43. * @param int $id Effect identifier.
  44. */
  45. public function __construct($id){
  46. $statement = get_context()->get_db()->prepare("
  47. SELECT
  48. id,
  49. name,
  50. is_buff,
  51. description
  52. FROM effect
  53. WHERE id = :id;
  54. ");
  55. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  56. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  57. if ($r){
  58. $this->id = $r["id"];
  59. $this->name = HTML::e($r["name"]);
  60. $this->is_buff = $r["is_buff"];
  61. $this->description = HTML::e($r["description"]);
  62. }
  63. }
  64. /**
  65. * Gets the pathto the monster image. The image must be in the
  66. * img/effect/ directory, and its name must be the effect id,
  67. * padded with '0' to 4 digits, and the extension must be '.png'.
  68. *
  69. * @return string Image URL, or a fixed unknown image.
  70. */
  71. public function get_image(){
  72. return APPLICATION::img("EFFECT", $this->id);
  73. }
  74. }
  75. ?>