|
|
@@ -171,8 +171,8 @@
|
|
|
$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->efficiency = $r["efficiency"];
|
|
|
+ $this->max_efficiency = $r["max_efficiency"];
|
|
|
$this->locked = $r["locked"];
|
|
|
|
|
|
// Get substats
|
|
|
@@ -201,8 +201,21 @@
|
|
|
}
|
|
|
$this->quality_name = $this->get_quality_name($this->quality);
|
|
|
$this->original_quality_name = $this->get_quality_name($this->original_quality);
|
|
|
- $this->efficiency = $this->calculate_efficiency();
|
|
|
- $this->max_efficiency = $this->calculate_maximum_efficiency();
|
|
|
+ if ($this->efficiency == null){
|
|
|
+ $this->efficiency = $this->calculate_efficiency();
|
|
|
+ $this->max_efficiency = $this->calculate_maximum_efficiency();
|
|
|
+ $statement = $db->prepare("
|
|
|
+ UPDATE rune
|
|
|
+ SET
|
|
|
+ efficiency = :eficiency,
|
|
|
+ max_efficiency = :max_efficiency
|
|
|
+ WHERE id = :rune
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':efficiency', $this->efficiency, SQLITE3_FLOAT);
|
|
|
+ $statement->bindValue(':max_efficiency', $this->max_efficiency, SQLITE3_FLOAT);
|
|
|
+ $statement->bindValue(':rune', $this->id, SQLITE3_INTEGER);
|
|
|
+ $q = $statement->execute();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -366,5 +379,78 @@
|
|
|
return $max_efficiency;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Calcuates how many rolls each substat has.
|
|
|
+ *
|
|
|
+ * DON'T USE: Error margins are as high as 85%, which is ridiculous.
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private function calculate_rolls(){
|
|
|
+ global $db;
|
|
|
+ $query = "
|
|
|
+ SELECT
|
|
|
+ min,
|
|
|
+ max
|
|
|
+ FROM
|
|
|
+ k_rune_roll_type,
|
|
|
+ k_rune_stat_roll
|
|
|
+ WHERE
|
|
|
+ k_rune_roll_type.id = k_rune_stat_roll.type AND
|
|
|
+ k_rune_roll_type.ancient = :ancient AND
|
|
|
+ k_rune_roll_type.initial = :initial AND
|
|
|
+ k_rune_roll_type.upgrade = :upgrade AND
|
|
|
+ k_rune_stat_roll.stars = :stars AND
|
|
|
+ k_rune_stat_roll.stat = :stat
|
|
|
+ ";
|
|
|
+ if ($this->innate_stat != null && $this->innate_stat->value > 0){
|
|
|
+ $this->innate_stat->rolls = 0;
|
|
|
+ $value = $this->innate_stat->value;
|
|
|
+ $statement = $db->prepare($query);
|
|
|
+ $statement->bindValue(':ancient', $this->ancient, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':initial', 1, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':upgrade', 0, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':stars', $this->stars, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':stat', $this->innate_stat->stat, SQLITE3_INTEGER);
|
|
|
+ $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
|
|
|
+ if ($r){
|
|
|
+ $min_initial = 0;//$r["min"];
|
|
|
+ $max_initial = $r["max"];
|
|
|
+ $this->innate_stat->efficiency = 100 * (($value - $min_initial) / ($max_initial - $min_initial));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $max_rolls = floor(max($this->level, 12) / 3);
|
|
|
+ $rolls = 0;
|
|
|
+ for ($i = 1; $i <= 4; $i ++){
|
|
|
+ if ($this->stats[$i] != null && $this->stats[$i]->value > 0){
|
|
|
+ $value = $this->stats[$i]->value;
|
|
|
+ $statement = $db->prepare($query);
|
|
|
+ $statement->bindValue(':ancient', $this->ancient, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':initial', 1, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':upgrade', 0, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':stars', $this->stars, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':stat', $this->stats[$i]->stat, SQLITE3_INTEGER);
|
|
|
+ $r_initial = $statement->execute()->fetchArray(SQLITE3_ASSOC);
|
|
|
+ $statement = $db->prepare($query);
|
|
|
+ $statement->bindValue(':ancient', $this->ancient, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':initial', 0, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':upgrade', 1, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':stars', $this->stars, SQLITE3_INTEGER);
|
|
|
+ $statement->bindValue(':stat', $this->stats[$i]->stat, SQLITE3_INTEGER);
|
|
|
+ $r_upgrade = $statement->execute()->fetchArray(SQLITE3_ASSOC);
|
|
|
+ if ($r_initial && $r_upgrade){
|
|
|
+ $min_initial = $r_initial["min"];
|
|
|
+ $max_initial = $r_initial["max"];
|
|
|
+ $avg_initial = ($min_initial + $max_initial) / 2;
|
|
|
+ $min_upgrade = $r_upgrade["min"];
|
|
|
+ $max_upgrade = $r_upgrade["max"];
|
|
|
+ $avg_upgrade = ($min_upgrade + $max_upgrade) / 2;
|
|
|
+ $rolls = round(max($value - $avg_initial, 0) / $avg_upgrade);
|
|
|
+ $this->stats[$i]->rolls = $rolls;
|
|
|
+ $this->stats[$i]->efficiency = ((5 * $value) - ( 4 * $min_upgrade + $min_initial)) / ( ($max_initial - $min_initial + (4 * ($max_upgrade + $min_upgrade))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
?>
|