prepare(" SELECT id, assigned_to, type, slot, stars, level, ancient, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind FROM rune WHERE id = :id; "); $statement->bindValue(':id', $id, SQLITE3_INTEGER); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["id"]; $this->assigned_to = $r["assigned_to"]; $this->type = new K_Rune_Set($r["type"]); $this->slot = $r["slot"]; $this->stars = $r["stars"]; $this->level = $r["level"]; $this->ancient = $r["ancient"]; $this->quality = $r["quality"]; $this->original_quality = $r["original_quality"]; $this->value = $r["value"]; $this->efficiency = $r["efficiency"]; $this->max_efficiency = $r["max_efficiency"]; $this->main_stat = $r["main_stat"]; $this->main_stat_value = $r["main_stat_value"]; $this->innate_stat = $r["innate_stat"]; $this->innate_stat_value = $r["innate_stat_value"]; $this->substat_1 = $r["substat_1"]; $this->substat_1_value = $r["substat_1_value"]; $this->substat_1_enchant = $r["substat_1_enchant"]; $this->substat_1_grind = $r["substat_1_grind"]; $this->substat_2 = $r["substat_2"]; $this->substat_2_value = $r["substat_2_value"]; $this->substat_2_enchant = $r["substat_2_enchant"]; $this->substat_2_grind = $r["substat_2_grind"]; $this->substat_3 = $r["substat_3"]; $this->substat_3_value = $r["substat_3_value"]; $this->substat_3_enchant = $r["substat_3_enchant"]; $this->substat_3_grind = $r["substat_3_grind"]; $this->substat_4 = $r["substat_4"]; $this->substat_4_value = $r["substat_4_value"]; $this->substat_4_enchant = $r["substat_4_enchant"]; $this->substat_4_grind = $r["substat_4_grind"]; $this->refresh_names(); } } /** * Gets the value of the main stat at an arbitrary level. * * @param int $level Desired level. * @return int Value of the main stat at the selected level. */ public function get_main_stat_at_level($level){ $level = intval($level); if ($level < 0 || $level > 15){ return 0; } switch ($this->main_stat){ case RUNE_STAT_ID::HP: return RUNE_STAT_VALUES::HP[$this->stars][$level]; case RUNE_STAT_ID::HP_P: return RUNE_STAT_VALUES::HP_P[$this->stars][$level]; case RUNE_STAT_ID::ATK: return RUNE_STAT_VALUES::ATK[$this->stars][$level]; case RUNE_STAT_ID::ATK_P: return RUNE_STAT_VALUES::ATK_P[$this->stars][$level]; case RUNE_STAT_ID::DEF: return RUNE_STAT_VALUES::DEF[$this->stars][$level]; case RUNE_STAT_ID::DEF_P: return RUNE_STAT_VALUES::DEF_P[$this->stars][$level]; case RUNE_STAT_ID::SPD: return RUNE_STAT_VALUES::SPD[$this->stars][$level]; case RUNE_STAT_ID::CRR: return RUNE_STAT_VALUES::CRR[$this->stars][$level]; case RUNE_STAT_ID::CRD: return RUNE_STAT_VALUES::CRD[$this->stars][$level]; case RUNE_STAT_ID::RES: return RUNE_STAT_VALUES::RES[$this->stars][$level]; case RUNE_STAT_ID::ACC: return RUNE_STAT_VALUES::ACC[$this->stars][$level]; default: return 0; } } /** * Calculates name variables. */ public function refresh_names(){ $this->main_stat_name = $this->stat_name($this->main_stat); $this->innate_stat_name = $this->stat_name($this->innate_stat); $this->substat_1_name = $this->stat_name($this->substat_1); $this->substat_2_name = $this->stat_name($this->substat_2); $this->substat_3_name = $this->stat_name($this->substat_3); $this->substat_4_name = $this->stat_name($this->substat_4); $this->quality_name = $this->get_quality_name($this->quality); $this->original_quality_name = $this->get_quality_name($this->original_quality); } /** * Gets a stat name from the mappings. * * @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 frm the mappings. * * @param int $q Quality id. * @return string Quality (Uppercase) */ private function get_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 ""; } } } ?>