K_Rune_Set.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * A rune set.
  5. *
  6. * Represents an object from the table 'k_rune_set'.
  7. */
  8. class K_Rune_Set extends Entity{
  9. /**
  10. * Set identifier.
  11. */
  12. public $id;
  13. /**
  14. * Set name.
  15. */
  16. public $name;
  17. /**
  18. * Required number of runes to activate the set.
  19. */
  20. public $amount;
  21. /**
  22. * Set description.
  23. */
  24. public $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 SQLite3 $db Connection to the database.
  32. * @param int $skill Effect identifier.
  33. */
  34. public function __construct($db, $id){
  35. global $path;
  36. parent::__construct($db);
  37. $s =
  38. "SELECT " .
  39. " id, " .
  40. " name, " .
  41. " amount, " .
  42. " description " .
  43. "FROM k_rune_set " .
  44. "WHERE id = $id;";
  45. $q = $this->db->query($s);
  46. $r = $q->fetchArray(SQLITE3_ASSOC);
  47. if ($r){
  48. $this->id = $r["id"];
  49. $this->name = $r["name"];
  50. $this->amount = $r["amount"];
  51. $this->description = $r["description"];
  52. }
  53. }
  54. public function get_image(){
  55. global $base_dir;
  56. global $path;
  57. if (file_exists($base_dir . "img/layout/rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png")){
  58. return $path["img"]["layout"] . "rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png";
  59. }
  60. else{
  61. return $path["img"]["layout"] . "unknown.png";
  62. }
  63. }
  64. }
  65. ?>