| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /**
- * Effect 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");
- /**
- * Skill effect.
- *
- * Represents an effect a skill can induce.
- *
- * @category Entity
- */
- class Effect extends Entity{
- /**
- * @var int Effect ID.
- */
- private $id;
- /**
- * @var string Effect name.
- */
- private $name;
- /**
- * @var bool Indicates if the effect is a buff.
- */
- private $is_buff;
- /**
- * @var string Effect description.
- */
- private $description;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * skill level, populating it and it's items.
- *
- * @param int $id Effect identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- id,
- name,
- is_buff,
- description
- FROM effect
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->name = HTML::e($r["name"]);
- $this->is_buff = $r["is_buff"];
- $this->description = HTML::e($r["description"]);
- }
- }
- /**
- * Retrieves the effect identifier.
- *
- * @return int Effect ID.
- */
- public function get_id(){
- return $this->id;
- }
- /**
- * Retrieves the effect name.
- *
- * @return string Effect name.
- */
- public function get_name(){
- return $this->name;
- }
- /**
- * Checks if the effect is a a buff (a good effect).
- *
- * @return bool True if buff, false if not.
- */
- public function is_buff(){
- return $this->is_buff;
- }
- /**
- * Checks if the efect is a a debuff (a bad effect).
- *
- * @return bool True if buff, false if not.
- */
- public function is_debuff(){
- return ! $this->is_buff;
- }
- /**
- * Retrieves the effect description.
- *
- * @return string Effect description.
- */
- public function get_description(){
- return $this->description;
- }
- /**
- * Gets the pathto the monster image.
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image(){
- return APPLICATION::img("EFFECT", $this->id);
- }
- }
|