improve 2
This commit is contained in:
@@ -572,28 +572,49 @@ func (r Rule) ValidateStats() error {
|
||||
}
|
||||
|
||||
func evaluateClassSkillsSum(it data.Item) int {
|
||||
// Check all class skills stats
|
||||
totalClassSkills := 0
|
||||
|
||||
for layer := 0; layer <= maxClassSkillsLayer; layer++ {
|
||||
if itemStat, found := it.FindStat(stat.AddClassSkills, layer); found && itemStat.Value > 0 {
|
||||
totalClassSkills += itemStat.Value
|
||||
}
|
||||
return evaluatePositiveStatSum(it, stat.AddClassSkills, maxClassSkillsLayer)
|
||||
}
|
||||
|
||||
return totalClassSkills
|
||||
}
|
||||
func evaluateSkillTabSum(it data.Item) int {
|
||||
// Check all skill tab stats
|
||||
totalSkillTabs := 0
|
||||
|
||||
for layer := 0; layer <= maxSkillTabLayer; layer++ {
|
||||
if itemStat, found := it.FindStat(stat.AddSkillTab, layer); found && itemStat.Value > 0 {
|
||||
totalSkillTabs += itemStat.Value
|
||||
}
|
||||
return evaluatePositiveStatSum(it, stat.AddSkillTab, maxSkillTabLayer)
|
||||
}
|
||||
|
||||
return totalSkillTabs
|
||||
const aggregateLayerFastPathLimit = 64
|
||||
|
||||
func evaluatePositiveStatSum(it data.Item, statID stat.ID, maxLayer int) int {
|
||||
// Current aggregate aliases fit in a small stack bitmap; retain the general
|
||||
// lookup path if additional layers later exceed that bound.
|
||||
if maxLayer >= aggregateLayerFastPathLimit {
|
||||
total := 0
|
||||
for layer := 0; layer <= maxLayer; layer++ {
|
||||
if itemStat, found := it.FindStat(statID, layer); found && itemStat.Value > 0 {
|
||||
total += itemStat.Value
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
var foundLayers [aggregateLayerFastPathLimit]bool
|
||||
total := 0
|
||||
for _, itemStat := range it.Stats {
|
||||
if itemStat.ID != statID || itemStat.Layer < 0 || itemStat.Layer > maxLayer || foundLayers[itemStat.Layer] {
|
||||
continue
|
||||
}
|
||||
foundLayers[itemStat.Layer] = true
|
||||
if itemStat.Value > 0 {
|
||||
total += itemStat.Value
|
||||
}
|
||||
}
|
||||
for _, itemStat := range it.BaseStats {
|
||||
if itemStat.ID != statID || itemStat.Layer < 0 || itemStat.Layer > maxLayer || foundLayers[itemStat.Layer] {
|
||||
continue
|
||||
}
|
||||
foundLayers[itemStat.Layer] = true
|
||||
if itemStat.Value > 0 {
|
||||
total += itemStat.Value
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func maxAliasLayer(statID stat.ID) int {
|
||||
|
||||
Reference in New Issue
Block a user