K_Leader_Skill.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Monster skill.
  5. *
  6. * Represents an object from the table 'k_skill'.
  7. */
  8. class K_Leader_Skill extends Entity{
  9. /**
  10. * Skill identifier.
  11. */
  12. public $id;
  13. /**
  14. * Skill attribute.
  15. */
  16. public $attribute;
  17. /**
  18. * Attribute incrrease amount.
  19. */
  20. public $amount;
  21. /**
  22. * Effect area.
  23. */
  24. public $area;
  25. /**
  26. * Affected elements.
  27. */
  28. public $element;
  29. /**
  30. * Constructor.
  31. *
  32. * Searches the database and retrieves the information about the
  33. * skill, populating it and it's items.
  34. *
  35. * @param SQLite3 $db Connection to the database.
  36. * @param int $id Skill identifier.
  37. */
  38. public function __construct($db, $id){
  39. global $path;
  40. parent::__construct($db);
  41. $s =
  42. "SELECT " .
  43. " id, " .
  44. " attribute, " .
  45. " amount, " .
  46. " area, " .
  47. " element " .
  48. "FROM k_leader_skill " .
  49. "WHERE id = $id; ";
  50. $q = $this->db->query($s);
  51. $r = $q->fetchArray(SQLITE3_ASSOC);
  52. $this->id = $r["id"];
  53. $this->attribute = $r["attribute"];
  54. $this->amount = $r["amount"];
  55. $this->area = $r["area"];
  56. $this->element = $r["element"];
  57. }
  58. public function get_image(){
  59. global $base_dir;
  60. global $path;
  61. if (file_exists($base_dir . "img/content/skill_leader/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
  62. return $path["img"]["content"] . "skill_leader/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
  63. }
  64. else{
  65. return $path["img"]["layout"] . "unknown.png";
  66. }
  67. }
  68. public function create_description(){
  69. $s = "Increases the " . $this->attribute . " of ally monsters ";
  70. if (strlen($this->element) > 0){
  71. $s = $s . " with " . $this->element . " attribute ";
  72. }
  73. $s = $s . " by " . $this->amount . "%";
  74. switch ($this->area){
  75. case "Dungeon":
  76. $s = $s . " in the Dungeons";
  77. break;
  78. case "Arena":
  79. $s = $s . " in the Arena";
  80. break;
  81. case "Guild":
  82. $s = $s . " in Guild content";
  83. break;
  84. }
  85. $s = $s . ".";
  86. return $s;
  87. }
  88. }
  89. ?>