Skill_Level.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Skill level 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. * Monster skill level.
  14. *
  15. * Represents an upgrade of a skill
  16. *
  17. * @category Entity
  18. */
  19. class Skill_Level extends Entity{
  20. /**
  21. * @var int Skill identifier.
  22. */
  23. private $skill;
  24. /**
  25. * @var int Skill level.
  26. */
  27. private $level;
  28. /**
  29. * @var string Upgrade description.
  30. */
  31. private $description;
  32. /**
  33. * Constructor.
  34. *
  35. * Searches the database and retrieves the information about the
  36. * skill level, populating it and it's items.
  37. *
  38. * @param int $skill Skill identifier.
  39. * @param int $level Skill level.
  40. */
  41. public function __construct($skill, $level){
  42. $statement = get_context()->get_db()->prepare("
  43. SELECT
  44. skill,
  45. level,
  46. description
  47. FROM skill_level
  48. WHERE
  49. skill = :skill AND
  50. level = :level;
  51. ");
  52. $statement->bindValue(':skill', $skill, SQLITE3_TEXT);
  53. $statement->bindValue(':level', $level, SQLITE3_TEXT);
  54. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  55. if ($r){
  56. $this->skill = $r["skill"];
  57. $this->level = $r["level"];
  58. $this->description = HTML::e($r["description"]);
  59. }
  60. }
  61. /**
  62. * Retrieves the skill identifier.
  63. *
  64. * @return int Skill ID.
  65. */
  66. public function get_skill(){
  67. return $this->skill;
  68. }
  69. /**
  70. * Retrieves the skill level.
  71. *
  72. * @return int Skill level.
  73. */
  74. public function get_level(){
  75. return $this->level;
  76. }
  77. /**
  78. * Retrieves the upgrade at this level.
  79. *
  80. * @return string Skill level description.
  81. */
  82. public function get_description(){
  83. return $this->description;
  84. }
  85. }