| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?php
- /**
- * Rune craft items entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- require_once(PATH::ENTITY . "K_Rune_Set.php");
- /**
- * Owned rune craft item.
- *
- * Represents an object from the table 'rune_craft'.
- *
- * @category Entity
- */
- class Rune_Craft extends Entity{
- /**
- * @var int Owner identifier.
- */
- public $uid;
- /**
- * @var int Item identifier.
- */
- public $id;
- /**
- * @var int Item quality.
- *
- * @see QUALITY
- */
- public $quality;
- /**
- * @var string Item quality name.
- */
- public $quality_name;
- /**
- * @var K_Rune_Set Rune set the item can be used on.
- */
- public $rune;
- /**
- * @var int Stat the item modifies.
- *
- * @see RUNE_STAT
- */
- public $stat;
- /**
- * @var string Stat name.
- */
- public $stat_name;
- /**
- * @var bool Indicates if the Item is a gem.
- */
- public $gem;
- /**
- * @var bool Indicates if the Item is ancient.
- */
- public $ancient;
- /**
- * @var bool Indicates if the Item is inmemorial.
- */
- public $inmemorial;
- /**
- * @var string Item name.
- */
- public $name;
- /**
- * @var int Minimum value of the stat.
- */
- public $min;
- /**
- * @var int Maximum value of the stat.
- */
- public $max;
- /**
- * @var int Sell value.
- */
- public $value;
- /**
- * @var int Number of item of this type owned.
- */
- public $amount;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * rune, populating it and it's items.
- *
- * @param int $id Rune id.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $s = "
- SELECT
- rune_craft.id AS id,
- rune_craft.quality As quality,
- rune_craft.rune AS rune,
- rune_craft.stat AS stat,
- rune_craft.value AS value,
- rune_craft.amount AS amount,
- k_rune_craft_type.name AS name,
- k_rune_craft_type.gem AS gem,
- k_rune_craft_type.inmemorial AS inmemorial,
- k_rune_craft_type.ancient AS ancient,
- k_rune_craft_range.min AS min,
- k_rune_craft_range.max AS max
- FROM
- rune_craft,
- k_rune_craft_type,
- k_rune_craft_range
- WHERE
- rune_craft.id = $id AND
- rune_craft.type = k_rune_craft_type.id AND
- k_rune_craft_type.gem = k_rune_craft_range.gem AND
- k_rune_craft_type.gem = k_rune_craft_range.gem AND
- k_rune_craft_type.ancient = k_rune_craft_range.ancient AND
- rune_craft.quality = k_rune_craft_range.quality AND
- rune_craft.stat = k_rune_craft_range.stat;
- ";
- $q = $db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->gem = $r["gem"];
- $this->quality = $r["quality"];
- $this->quality_name = $this->quality_name($r["quality"]);
- $this->stat = $r["stat"];
- $this->stat_name = $this->stat_name($r["stat"]);
- $this->ancient = $r["ancient"];
- $this->inmemorial = $r["inmemorial"];
- if ($this->inmemorial == 0){
- $this->rune = new K_Rune_Set($r["rune"]);
- $this->name = $this->rune->name . " " . $r["stat"];
- }
- else{
- $this->name = "Inmemorial " . $r["stat"];
- }
- $this->min = $r["min"];
- $this->max = $r["max"];
- $this->value = $r["value"];
- $this->amount = $r["amount"];
- }
- }
- /**
- * Gets a stat name from the maps.
- *
- * @param int $stat Stat id.
- * @return string Stat name (Uppercase)
- */
- private function stat_name($stat){
- switch ($stat){
- case RUNE_STAT_ID::HP:
- return "HP";
- case RUNE_STAT_ID::HP_P:
- return "HP%";
- case RUNE_STAT_ID::ATK:
- return "ATK";
- case RUNE_STAT_ID::ATK_P:
- return "ATK%";
- case RUNE_STAT_ID::DEF:
- return "DEF";
- case RUNE_STAT_ID::DEF_P:
- return "DEF%";
- case RUNE_STAT_ID::SPD:
- return "SPD";
- case RUNE_STAT_ID::CRR:
- return "CRR";
- case RUNE_STAT_ID::CRD:
- return "CRD";
- case RUNE_STAT_ID::RES:
- return "RES";
- case RUNE_STAT_ID::ACC:
- return "ACC";
- default:
- return "";
- }
- }
- /**
- * Gets a stat name from the maps.
- *
- * @param int $q Quality id.
- * @return string Quality (Uppercase)
- */
- private function quality_name($q){
- switch ($q){
- case QUALITY_ID::NORMAL:
- return "NORMAL";
- case QUALITY_ID::MAGIC:
- return "MAGIC";
- case QUALITY_ID::RARE:
- return "RARE";
- case QUALITY_ID::HERO:
- return "HERO";
- case QUALITY_ID::LEGEND:
- return "LEGEND";
- default:
- return "";
- }
- }
- }
- ?>
|