bugfixing, performance improvements and added casting frames formula

This commit is contained in:
Héctor Giménez
2024-05-09 20:27:31 +09:00
parent 0c6a2c17ab
commit c398062b57
14 changed files with 293 additions and 216 deletions

View File

@@ -175,13 +175,6 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
return RuleResultNoMatch, fmt.Errorf("property %s is not valid or not supported", statName)
}
// Exception for enhanceddefense, is not accurate
if strings.EqualFold(statName, "enhanceddefense") {
enhancedDefense := r.calculateEnhancedDefense(it)
stage2Props[statName] = enhancedDefense
continue
}
layer := 0
if len(statData) > 1 {
layer = statData[1]
@@ -249,32 +242,3 @@ func getRequiredStatsForRule(line string) []string {
func (r Rule) MaxQuantity() int {
return r.maxQuantity
}
func (r Rule) calculateEnhancedDefense(i data.Item) int {
defenseStat, found := i.FindStat(stat.Defense, 0)
// This is special case for weapons and other stuff without base Defense and with EnhancedDefense, we can return it directly
// since EnhancedDefense it's a stat.
if !found {
if edStat, edStatFound := i.FindStat(stat.EnhancedDefense, 0); edStatFound {
return edStat.Value
}
}
// Make it only work for white base items
if i.Quality != item.QualitySuperior {
return 0
}
if !i.Type().IsType(item.TypeArmor) {
return 0
}
itemTypeMaxDefense := i.Desc().MaxDefense
if defenseStat.Value <= itemTypeMaxDefense {
return 0
}
return int(float64(defenseStat.Value-itemTypeMaxDefense) / float64(itemTypeMaxDefense) * 100)
}