| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- /**
- * Leader skill entity file.
- *
- * Creates the entity and makes it available.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Monster leader skill.
- *
- * Represents a leader skill
- *
- * @category Entity
- */
- class Leader_Skill extends Entity{
- /**
- * @var int Leader skill identifier.
- */
- private $id;
- /**
- * @var int ID of the stat augmented by the leader skill.
- */
- private $stat;
- /**
- * @var int Amount the stat is increased by.
- */
- private $amount;
- /**
- * @var int Effect area id (if any).
- */
- private $area;
- /**
- * @var int Affected element id (if any).
- */
- private $element;
- /**
- * @var string Human readable description of the skill.
- */
- private $description;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * skill, populating it and it's items.
- *
- * @param int $id Skill identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- id,
- stat,
- amount,
- area,
- element
- FROM leader_skill
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->stat = $r["stat"];
- $this->amount = $r["amount"];
- $this->area = $r["area"];
- $this->element = $r["element"];
- $this->description = $this->create_description();
- }
- }
- /**
- * Retrieves the leader skill identifier.
- *
- * @return string Leader skill ID.
- */
- public function get_id(){
- return $this->id;
- }
- /**
- * Retrieves $stat
- *
- * @return int
- */
- public function get_stat(){
- return $this->stat;
- }
- /**
- * Retrieves $amount
- *
- * @return int
- */
- public function get_amount(){
- return $this->amount;
- }
- /**
- * Retrieves $area
- *
- * @return int
- */
- public function get_area(){
- return $this->area;
- }
- /**
- * Retrieves $element
- *
- * @return int
- */
- public function get_element(){
- return $this->element;
- }
- /**
- * Retrieves the skill description.
- *
- * @return string Skill description.
- */
- public function get_description(){
- return $this->description;
- }
- /**
- * Gets the path to the skill image.
- * @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.
- */
- private function create_description(){
- $s = "Increases the ";
- switch ($this->stat){
- 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::ACCURACY:
- $s .= "accuracy";
- break;
- case STAT_ID::RESIST:
- $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 = str_replace(" ", " ", $s) . ".";
- return $s;
- }
- }
|