| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /**
- * Artifact stat entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /*
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Artifact_stat.
- *
- * Represents an object from the table 'artifact_stat'.
- *
- * @category Entity
- */
- class Artifact_Stat extends Entity{
- private $stat;
- private $name = "";
- private $value;
- /**
- * Constructor.
- *
- * Retrieves the artifact stat information from the database.
- *
- * @param int $artifact_id Artifact id.
- */
- public function __construct($artifact_id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- stat,
- value
- FROM artifact_stat
- WHERE
- artifact = :artifact
- ");
- $statement->bindValue(':artifact', $artifact_id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->stat = $r["stat"];
- $this->value = $r["value"];
- switch ($this->stat){
- case ARTIFACT_STAT_ID::HP:
- $this->name = "HP";
- break;
- case ARTIFACT_STAT_ID::ATK:
- $this->name = "ATK";
- break;
- case ARTIFACT_STAT_ID::DEF:
- $this->name = "DEF";
- break;
- }
- }
- }
- /**
- * Retrieves the artifact stat identifier.
- *
- * @see ARTIFACT_STAT_ID
- *
- * @return int Artifact stat ID.
- */
- public function get_stat(){
- return $this->stat;
- }
- /**
- * Retrieves the artifact stat name.
- *
- * @return string Artifact stat name.
- */
- public function get_name(){
- return $this->name;
- }
- /**
- * Retrieves the value of the artifact stat value.
- *
- * @return number Stat value.
- */
- public function get_value(){
- return $this->value;
- }
- }
- ?>
|