K_Leader_Skill.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * Leader skill 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. * Monster skill.
  15. *
  16. * Represents an object from the table 'k_skill'.
  17. *
  18. * @category Entity
  19. */
  20. class K_Leader_Skill extends Entity{
  21. /**
  22. * @var int Skill identifier.
  23. */
  24. public $id;
  25. /**
  26. * @var int Skill attribute ID.
  27. */
  28. public $attribute;
  29. /**
  30. * @var int Attribute increase amount.
  31. */
  32. public $amount;
  33. /**
  34. * @var int Effect area id.
  35. */
  36. public $area;
  37. /**
  38. * @var int Affected element id.
  39. */
  40. public $element;
  41. /**
  42. * Constructor.
  43. *
  44. * Searches the database and retrieves the information about the
  45. * skill, populating it and it's items.
  46. *
  47. * @param resource $db Connection to the database.
  48. * @param int $id Skill identifier.
  49. */
  50. public function __construct($db, $id){
  51. parent::__construct($db);
  52. $s =
  53. "SELECT " .
  54. " id, " .
  55. " stat, " .
  56. " amount, " .
  57. " area, " .
  58. " element " .
  59. "FROM k_leader_skill " .
  60. "WHERE id = $id; ";
  61. $q = $this->db->query($s);
  62. $r = $q->fetchArray(SQLITE3_ASSOC);
  63. $this->id = $r["id"];
  64. $this->attribute = $r["stat"];
  65. $this->amount = $r["amount"];
  66. $this->area = $r["area"];
  67. $this->element = $r["element"];
  68. }
  69. /**
  70. * Gets the path to the skill image. The image must be in the
  71. * img/skill_leader/ directory, and its name must be the skill id,
  72. * padded with '0' to 4 digites, and the extension must be '.png'.
  73. *
  74. * @return string Image URL, or a fixed unknown image.
  75. */
  76. public function get_image(){
  77. return APPLICATION::img("SKILL_LEADER", $this->id);
  78. }
  79. /**
  80. * Composes a human readable description of the skill.
  81. *
  82. * @return string The description.
  83. */
  84. public function create_description(){
  85. global $STAT;
  86. global $ELEMENT;
  87. global $EFFECT_AREA;
  88. $s = "Increases the ";
  89. switch ($this->attribute){
  90. case STAT_ID::ATK:
  91. $s .= "attack power";
  92. break;
  93. case STAT_ID::DEF:
  94. $s .= "defense";
  95. break;
  96. case STAT_ID::HP:
  97. $s .= "HP";
  98. break;
  99. case STAT_ID::SPD:
  100. $s .= "attack speed";
  101. break;
  102. case STAT_ID::CRIT_RATE:
  103. $s .= "critical rate";
  104. break;
  105. case STAT_ID::CRIT_DMG:
  106. $s .= "critical damage";
  107. break;
  108. case STAT_ID::ACC:
  109. $s .= "accuracy";
  110. break;
  111. case STAT_ID::RES:
  112. $s .= "resistance";
  113. break;
  114. }
  115. $s .= " of ally monsters ";
  116. switch ($this->element){
  117. case ELEMENT_ID::WATER:
  118. $s .= " with Water attribute ";
  119. break;
  120. case ELEMENT_ID::FIRE:
  121. $s .= " with Fire attribute ";
  122. break;
  123. case ELEMENT_ID::WIND:
  124. $s .= " with Wind attribute ";
  125. break;
  126. case ELEMENT_ID::LIGHT:
  127. $s .= " with Light attribute ";
  128. break;
  129. case ELEMENT_ID::DARK:
  130. $s .= " with Dark attribute ";
  131. break;
  132. }
  133. $s = $s . "by " . $this->amount . "%";
  134. switch ($this->area){
  135. case EFFECT_AREA_ID::DUNGEON:
  136. $s = $s . " in the Dungeons";
  137. break;
  138. case EFFECT_AREA_ID::ARENA:
  139. $s = $s . " in the Arena";
  140. break;
  141. case EFFECT_AREA_ID::GUILD:
  142. $s = $s . " in Guild content";
  143. break;
  144. }
  145. $s = $s . ".";
  146. return $s;
  147. }
  148. }
  149. ?>