| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- /**
- * Artifact effect entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /*
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Artifact effect.
- *
- * Represents an object from the table 'artifact_effect'.
- *
- * @category Entity
- */
- class Artifact_Effect extends Entity{
- private $slot;
- private $effect;
- private $name = "";
- private $value;
- private $grind;
- private $enchant;
- /**
- * Constructor.
- *
- * Retrieves the artifact effect information from the database.
- *
- * @param int $artifact Artifact id.
- * @param int $slot Artifact slot id.
- */
- public function __construct($artifact, $slot){
- $statement = get_context()->get_db()->prepare("
- SELECT
- slot,
- effect,
- value,
- enchant,
- grind
- FROM artifact_effect
- WHERE
- artifact = :artifact AND
- slot = :slot;
- ");
- $statement->bindValue(':artifact', $artifact, SQLITE3_TEXT);
- $statement->bindValue(':slot', $slot, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->effect = $r["effect"];
- $this->value = $r["value"];
- $this->enchant = $r["enchant"];
- $this->grind = $r["grind"];
- $statement = get_context()->get_db()->prepare("
- SELECT name
- FROM effect_artifact
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $this->effect, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->name = str_replace("{}", $this->value, $r["name"]);
- }
- }
- }
- /**
- * Retrieves the artifact effect's slot identifier.
- *
- * @see ARTIFACT_EFFECT_SLOT_ID
- *
- * @return int Effect slot ID.
- */
- public function get_slot(){
- return $this->slot;
- }
-
- /**
- * Artifact effect identifier.
- *
- * @return int Effect ID.
- */
- public function get_effect(){
- return $this->effect;
- }
-
- /**
- * Retrieves the artifact effect name.
- *
- * @return string The effect name.
- */
- public function get_name(){
- return $this->name;
- }
-
- /**
- * Retrieves the value of the artifact effect, excluding grinds.
- *
- * @return number Effect value.
- */
- public function get_value(){
- return $this->value;
- }
-
- /**
- * Retrieves the grinded value on the effect.
- *
- * @return number Effect grinded value.
- */
- public function get_grind(){
- return $this->grind;
- }
-
- /**
- * Checks if the effect has been enchanted.
- *
- * @return boolean True if the effect was enchanted, false otherwise
- */
- public function is_enchanted(){
- return filter_var($this->enchant, FILTER_VALIDATE_BOOLEAN);
- }
- }
- ?>
|