| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- /**
- * Leader skill entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Monster skill.
- *
- * Represents an object from the table 'k_skill'.
- *
- * @category Entity
- */
- class K_Leader_Skill extends Entity{
- /**
- * @var int Skill identifier.
- */
- public $id;
- /**
- * @var int Skill attribute ID.
- */
- public $attribute;
- /**
- * @var int Attribute increase amount.
- */
- public $amount;
- /**
- * @var int Effect area id.
- */
- public $area;
- /**
- * @var int Affected element id.
- */
- public $element;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * skill, populating it and it's items.
- *
- * @param int $id Skill identifier.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $s =
- "SELECT " .
- " id, " .
- " stat, " .
- " amount, " .
- " area, " .
- " element " .
- "FROM k_leader_skill " .
- "WHERE id = $id; ";
- $q = $db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->id = $r["id"];
- $this->attribute = $r["stat"];
- $this->amount = $r["amount"];
- $this->area = $r["area"];
- $this->element = $r["element"];
- }
- /**
- * Gets the path to the skill image. The image must be in the
- * img/skill_leader/ directory, and its name must be the skill id,
- * padded with '0' to 4 digites, and the extension must be '.png'.
- *
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image(){
- return APPLICATION::img("SKILL_LEADER", $this->id);
- }
- /**
- * Composes a human readable description of the skill.
- *
- * @return string The description.
- */
- public function create_description(){
- $s = "Increases the ";
- switch ($this->attribute){
- case STAT_ID::ATK:
- $s .= "attack power";
- break;
- case STAT_ID::DEF:
- $s .= "defense";
- break;
- case STAT_ID::HP:
- $s .= "HP";
- break;
- case STAT_ID::SPD:
- $s .= "attack speed";
- break;
- case STAT_ID::CRIT_RATE:
- $s .= "critical rate";
- break;
- case STAT_ID::CRIT_DMG:
- $s .= "critical damage";
- break;
- case STAT_ID::ACC:
- $s .= "accuracy";
- break;
- case STAT_ID::RES:
- $s .= "resistance";
- break;
- }
- $s .= " of ally monsters ";
- switch ($this->element){
- case ELEMENT_ID::WATER:
- $s .= " with Water attribute ";
- break;
- case ELEMENT_ID::FIRE:
- $s .= " with Fire attribute ";
- break;
- case ELEMENT_ID::WIND:
- $s .= " with Wind attribute ";
- break;
- case ELEMENT_ID::LIGHT:
- $s .= " with Light attribute ";
- break;
- case ELEMENT_ID::DARK:
- $s .= " with Dark attribute ";
- break;
- }
- $s = $s . "by " . $this->amount . "%";
- switch ($this->area){
- case EFFECT_AREA_ID::DUNGEON:
- $s = $s . " in the Dungeons";
- break;
- case EFFECT_AREA_ID::ARENA:
- $s = $s . " in the Arena";
- break;
- case EFFECT_AREA_ID::GUILD:
- $s = $s . " in Guild content";
- break;
- }
- $s = $s . ".";
- return $s;
- }
- }
- ?>
|