K_Rune_Set.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Rune set 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. * A rune set.
  15. *
  16. * Represents an object from the table 'k_rune_set'.
  17. *
  18. * @category Entity
  19. */
  20. class K_Rune_Set extends Entity{
  21. /**
  22. * @var int Set identifier.
  23. */
  24. public $id;
  25. /**
  26. * @var string Set name.
  27. */
  28. public $name;
  29. /**
  30. * @var int Required number of runes to activate the set.
  31. */
  32. public $amount;
  33. /**
  34. * @var string Set description.
  35. */
  36. public $description;
  37. /**
  38. * Constructor.
  39. *
  40. * Searches the database and retrieves the information about the
  41. * set, populating it and it's items.
  42. *
  43. * @param int $id Set identifier.
  44. * @global resource Database connection.
  45. */
  46. public function __construct($id){
  47. global $db;
  48. $statement = $db->prepare("
  49. SELECT
  50. id,
  51. name,
  52. amount,
  53. description
  54. FROM k_rune_set
  55. WHERE id = :id;
  56. ");
  57. $statement->bindValue(':id', $id, SQLITE3_INTEGER);
  58. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  59. if ($r){
  60. $this->id = $r["id"];
  61. $this->name = HTML::e($r["name"]);
  62. $this->amount = $r["amount"];
  63. $this->description = HTML::e($r["description"]);
  64. }
  65. }
  66. /**
  67. * Gets the path to the set image. The image must be in the
  68. * img/rune/ directory, and its name must be the set id,
  69. * padded with '0' to 2 digits, and the extension must be '.png'.
  70. *
  71. * @return string Image URL, or a fixed unknown image.
  72. */
  73. public function get_image(){
  74. return APPLICATION::img("RUNE", $this->id);
  75. }
  76. }
  77. ?>