get_db()->prepare(" SELECT enchantment.player AS player, enchantment.id AS id, enchantment.quality As quality, enchantment.rune AS rune, enchantment.stat AS stat, enchantment.value AS value, enchantment.amount AS amount, enchantment_type.name AS name, enchantment_type.gem AS gem, enchantment_type.inmemorial AS inmemorial, enchantment_type.ancient AS ancient, enchantment_range.min AS min, enchantment_range.max AS max FROM enchantment, enchantment_type, enchantment_range WHERE enchantment.id = :id AND enchantment.type = enchantment_type.id AND enchantment_type.gem = enchantment_range.gem AND enchantment_type.gem = enchantment_range.gem AND enchantment_type.ancient = enchantment_range.ancient AND enchantment.quality = enchantment_range.quality AND enchantment.stat = enchantment_range.stat; "); $statement->bindValue(':id', $id, SQLITE3_TEXT); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->player_id = $r["player"]; $this->id = $r["id"]; if ($r["gem"] == 0){ $this->gem = false; } else{ $this->gem = true; } $this->quality = $r["quality"]; $this->quality_name = $this->quality_name($r["quality"]); $this->stat = $r["stat"]; $this->stat_name = $this->stat_name($r["stat"]); if ($r["ancient"] == 0){ $this->ancient = false; } else{ $this->ancient = true; } $this->inmemorial = $r["inmemorial"]; if ($r["inmemorial"] == 0){ $this->rune_set = new Rune_Set($r["rune"]); $this->name = $this->rune_set->get_name() . " " . $r["stat"]; $this->inmemorial = false; } else{ $this->inmemorial = true; $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 ""; } } /** * Calculates name variables. */ public function refresh_names(){ $this->stat_name = $this->stat_name($this->stat); $this->quality_name = $this->quality_name($this->quality); $this->name = $this->rune->name . " " . $this->stat; if ($this->inmemorial == 0){ $this->name = $this->rune->name . " " . $this->stat; } else{ $this->name = "Inmemorial " . $this->stat; } } /** * Retrieves the owner's player identifier. * * @return int player identifier. */ public function get_player_id(){ return $this->player_id; } /** * Retrieves the enchantment identifier. * * @return string Enchantment ID. */ public function get_id(){ return $this->id; } /** * Retrieves the quality of the enchantment. * * @see QUALITY_ID * * @return int Quality. */ public function get_quality(){ return $this->quality; } /** * Retrieves the quality name of the enchantment. * * @return string Quality name. */ public function get_quality_name(){ return $this->quality_name; } /** * Retrieves the rune set the enchantment can be used on. * * @return Rune_Set The set the enchantment can be used on, null for inmemorials. */ public function get_rune_set(){ return $this->rune_set; } /** * Retrieves the stat affected by the enchantment. * * @see RUNE_STAT_ID * * @return int Stat ID. */ public function get_stat(){ return $this->stat; } /** * Retrieves the name of the affected stat. * * @return string Stat name */ public function get_stat_name(){ return $this->stat_name; } /** * Checks if the enchantment is a enchanted gem. * * @return boolean true for enchanted gems, false for grindstones. */ public function is_gem(){ return $this->gem; } /** * Checks if the enchantment is a grindstone. * * @return boolean true for grindstones, false enchanted gems. */ public function is_grind(){ return ! $this->gem; } /** * Checks if it's an ancient enchantment. * * @return boolean Tur if anciend, false if normal. */ public function is_ancient(){ return $this->ancient; } /** * Checks if the enchantment is inmemorial. * * @return boolean True for inmemorial, false otherwise. */ public function is_inmemorial(){ return $this->inmemorial; } /** * Retrieves the enchantment name. * * @return string Enchantment name. */ public function get_name(){ return $this->name; } /** * Retrieves the minumum value for the enchantment. * * @return int Minimum enchant outcome. */ public function get_min(){ return $this->min; } /** * Retrieves the maximum value for the enchantment. * * @return int maximum enchant outcome. */ public function get_max(){ return $this->max; } /** * Retrieves the value of the enchantment in mana stones. * * @return int Value of the enchantment. */ public function get_value(){ return $this->value; } /** * Retrieves the amount of the same enchantment owned by the user. * * @return int Number of the enchantments owned. */ public function get_amount(){ return $this->amount; } } ?>