Guild_Skill.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Guild skill 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. * Guild skill.
  14. *
  15. * Represents one of the guild skills aquired by leveling the guild up.
  16. *
  17. * @category Entity
  18. */
  19. class Guild_Skill extends Entity{
  20. /**
  21. * @var int Skill ID.
  22. */
  23. private $id;
  24. /**
  25. * @var int Skill group ID.
  26. */
  27. private $group;
  28. /**
  29. * @var int Reached skil level.
  30. */
  31. private $level;
  32. /**
  33. * @var string Skill bonus, human readable.
  34. */
  35. private $effect;
  36. /**
  37. * Constructor.
  38. *
  39. * Searches the database and retrieves the information about the
  40. * skill, populating it and it's items.
  41. *
  42. * @param int $id Skill identifier.
  43. */
  44. public function __construct($id){
  45. $statement = get_context()->get_db()->prepare("
  46. SELECT
  47. id,
  48. skill_group,
  49. level,
  50. effect
  51. FROM key.guild_skill
  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->group = $r["skill_group"];
  59. $this->level = $r["level"];
  60. $this->effect = HTML::e($r["effect"]);
  61. }
  62. }
  63. /**
  64. * Retrieves the guild skill identifier.
  65. *
  66. * @return int Skill ID.
  67. */
  68. public function get_id(){
  69. return $this->id;
  70. }
  71. /**
  72. * Retrieves the skill group identifier.
  73. *
  74. * @return int Group ID.
  75. */
  76. public function get_group(){
  77. return $this->group;
  78. }
  79. /**
  80. * Retrieves the skill level.
  81. *
  82. * @return int Skill level.
  83. */
  84. public function get_level(){
  85. return $this->level;
  86. }
  87. /**
  88. * Retrieves the skill efect description.
  89. *
  90. * @return string Skill description.
  91. */
  92. public function get_effect(){
  93. return $this->effect;
  94. }
  95. }