Implement handling for itemaddskilltab and itemaddclassskills
Added special handling for skill tabs and class skills in rule evaluation.
This commit is contained in:
@@ -310,6 +310,16 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
|
|||||||
stage2 = strings.ToLower(strings.Split(r.RawLine, "#")[1])
|
stage2 = strings.ToLower(strings.Split(r.RawLine, "#")[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special handling for skill tabs
|
||||||
|
if strings.Contains(stage2, "[itemaddskilltab]") {
|
||||||
|
stage2Props["itemaddskilltab"] = evaluateSkillTabSum(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special handling for class skills
|
||||||
|
if strings.Contains(stage2, "[itemaddclassskills]") {
|
||||||
|
stage2Props["itemaddclassskills"] = evaluateClassSkillsSum(it)
|
||||||
|
}
|
||||||
|
|
||||||
// Preprocess stage2 to see if certain stats are being compared to zero
|
// Preprocess stage2 to see if certain stats are being compared to zero
|
||||||
zeroCheckStats := make(map[string]bool)
|
zeroCheckStats := make(map[string]bool)
|
||||||
for _, statName := range r.requiredStats {
|
for _, statName := range r.requiredStats {
|
||||||
@@ -354,6 +364,10 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
|
|||||||
|
|
||||||
// Evaluate each required stat
|
// Evaluate each required stat
|
||||||
for _, statName := range r.requiredStats {
|
for _, statName := range r.requiredStats {
|
||||||
|
// Skip stats we've already handled
|
||||||
|
if statName == "itemaddskilltab" || statName == "itemaddclassskills" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
statData, found := statAliases[statName]
|
statData, found := statAliases[statName]
|
||||||
if !found {
|
if !found {
|
||||||
return RuleResultNoMatch, fmt.Errorf("property %s is not valid or not supported", statName)
|
return RuleResultNoMatch, fmt.Errorf("property %s is not valid or not supported", statName)
|
||||||
@@ -447,6 +461,31 @@ func getRequiredStatsForRule(line string) []string {
|
|||||||
return statsList
|
return statsList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func evaluateClassSkillsSum(it data.Item) int {
|
||||||
|
// Check all class skills stats (all have base ID 83 with different layers)
|
||||||
|
totalClassSkills := 0
|
||||||
|
|
||||||
|
for layer := 0; layer <= 6; layer++ {
|
||||||
|
if itemStat, found := it.FindStat(stat.ID(83), layer); found && itemStat.Value > 0 {
|
||||||
|
totalClassSkills += itemStat.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalClassSkills
|
||||||
|
}
|
||||||
|
func evaluateSkillTabSum(it data.Item) int {
|
||||||
|
// Check all skill tab stats (all have base ID 188 with different layers)
|
||||||
|
totalSkillTabs := 0
|
||||||
|
|
||||||
|
for layer := 0; layer <= 50; layer++ {
|
||||||
|
if itemStat, found := it.FindStat(stat.ID(188), layer); found && itemStat.Value > 0 {
|
||||||
|
totalSkillTabs += itemStat.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalSkillTabs
|
||||||
|
}
|
||||||
|
|
||||||
// MaxQuantity returns the maximum quantity of items that character can have, 0 means no limit
|
// MaxQuantity returns the maximum quantity of items that character can have, 0 means no limit
|
||||||
func (r Rule) MaxQuantity() int {
|
func (r Rule) MaxQuantity() int {
|
||||||
return r.maxQuantity
|
return r.maxQuantity
|
||||||
|
|||||||
Reference in New Issue
Block a user