| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?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{
- /**
- * @var int Stat of the artifact.
- *
- * @see ARTIFACT_STAT_ID
- */
- public $stat;
- /**
- * @var string Stat name (uppercase).
- */
- public $name = "";
- /**
- * @var int Stat value of the rune.
- */
- public $value;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * artifact stat, populating it and it's items.
- *
- * @param int $id Artifact id.
- * @global resource Database connection.
- */
- public function __construct($artifact){
- global $db;
- $statement = $db->prepare("
- SELECT
- stat,
- value
- FROM artifact_stat
- WHERE
- artifact = :artifact
- ");
- $statement->bindValue(':artifact', $artifact, 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;
- }
- }
- }
- }
- ?>
|