Return nip.Rule struct from Evaluate function in itemfilter (#14)

* Return Rule from –Evaluate in itemfilter

* Return Rule as the first argument
This commit is contained in:
13413j1j13j5315n13
2024-03-31 02:57:42 +02:00
committed by GitHub
parent d5d0f0a51f
commit 58b995842d
3 changed files with 7 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ import (
"github.com/hectorgimenez/d2go/pkg/nip"
)
func Evaluate(i data.Item, rules []nip.Rule) bool {
func Evaluate(i data.Item, rules []nip.Rule) (nip.Rule, bool) {
for _, r := range rules {
if !evaluateGroups(i, r.Properties, checkProperty) {
// Properties not matching, skipping
@@ -17,15 +17,15 @@ func Evaluate(i data.Item, rules []nip.Rule) bool {
// We can not check stats, item is not identified, but properties matching
if !i.Identified {
return true
return nip.Rule{}, true
}
if evaluateGroups(i, r.Stats, checkStat) {
return true
return r, true
}
}
return false
return nip.Rule{}, false
}
func evaluateGroups(i data.Item, groups []nip.Group, evalFunc func(i data.Item, prop nip.Comparable) bool) bool {