| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- /**
- * Artifact stat 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");
- /**
- * Artifact stat.
- *
- * Represents the artifact main stat.
- *
- * @category Entity
- */
- class Artifact_Stat extends Entity{
- /**
- * @var int Artifact stat ID ({@see ARTIFACT_STAT_ID}).
- */
- private $stat;
- /**
- * @var string Artifact stat name.
- */
- private $name;
- /**
- * @var int The value of the artifact stat.
- */
- 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;
- }
- }
- else{
- // Not found, maybe as a run drop?
- $statement = get_context()->get_db()->prepare("
- SELECT
- stat,
- stat_value
- FROM run_drop_artifact
- WHERE id = :artifact
- ");
- $statement->bindValue(':artifact', $artifact_id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->stat = $r["stat"];
- $this->value = $r["stat_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 int Stat value.
- */
- public function get_value(){
- return $this->value;
- }
- }
|