K_Rune_Set.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. error_log("RUNESET QUERY: " . $s);
  46. $q = $this->db->query($s);
  47. $r = $q->fetchArray(SQLITE3_ASSOC);
  48. if ($r){
  49. $this->id = $r["id"];
  50. $this->name = $r["name"];
  51. $this->amount = $r["amount"];
  52. $this->description = $r["description"];
  53. }
  54. }
  55. public function get_image(){
  56. global $base_dir;
  57. global $path;
  58. if (file_exists($base_dir . "img/layout/rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png")){
  59. return $path["img"]["layout"] . "rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png";
  60. }
  61. else{
  62. return $path["img"]["layout"] . "unknown.png";
  63. }
  64. }
  65. }
  66. ?>