query($s); $r = $q->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["id"]; $this->assigned_to = $r["assigned_to"]; $this->type = $r["type"]; $this->element = $r["attribute"]; $this->archetype = $r["archetype"]; $this->level = $r["level"]; $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->effect_1 = $r["effect_1"]; $this->effect_1_value = $r["effect_1_value"]; //$this->effect_1_enchant = $r["effect_1_enchant"]; //$this->effect_1_grind = $r["effect_1_grind"]; $this->effect_2 = $r["effect_2"]; $this->effect_2_value = $r["effect_2_value"]; //$this->effect_2_enchant = $r["effect_2_enchant"]; //$this->effect_2_grind = $r["effect_2_grind"]; $this->effect_3 = $r["effect_3"]; $this->effect_3_value = $r["effect_3_value"]; //$this->effect_3_enchant = $r["effect_3_enchant"]; //$this->effect_3_grind = $r["effect_3_grind"]; $this->effect_4 = $r["effect_4"]; $this->effect_4_value = $r["effect_4_value"]; //$this->effect_4_enchant = $r["effect_4_enchant"]; //$this->effect_4_grind = $r["effect_4_grind"]; $this->refresh_names(); } } /** * Calculates name variables. */ public function refresh_names(){ $this->main_stat_name = $this->stat_name($this->main_stat); $this->effect_1_description = $this->effect_description($this->effect_1, $this->effect_1_value); $this->effect_2_description = $this->effect_description($this->effect_2, $this->effect_2_value); $this->effect_3_description = $this->effect_description($this->effect_3, $this->effect_3_value); $this->effect_4_description = $this->effect_description($this->effect_4, $this->effect_4_value); $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 ARTIFACT_STAT_ID::HP: return "HP"; case ARTIFACT_STAT_ID::ATK: return "ATK"; case ARTIFACT_STAT_ID::DEF: return "DEF"; default: return ""; } } /** * Composes an effect description. * * @param int $effect Effect id. * @param int $value Effect value. * @return string Effect description, null if unavailable. * @global resource Database connection. */ private function effect_description($effect, $value){ global $db; $s = "SELECT name " . "FROM k_artifact_effect " . "WHERE id = '$effect'; "; $q = $db->query($s); $r = $q->fetchArray(SQLITE3_ASSOC); if ($r){ return str_replace("{}", $value, $r["name"]); } else{ return null; } } /** * Gets the quality name from 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 ""; } } } ?>