allow partial rules for specific item types
This commit is contained in:
@@ -55,12 +55,12 @@ func (w *Watcher) Start(ctx context.Context) error {
|
|||||||
d := w.gr.GetData()
|
d := w.gr.GetData()
|
||||||
for _, i := range d.Items.ByLocation(item.LocationGround) {
|
for _, i := range d.Items.ByLocation(item.LocationGround) {
|
||||||
for _, r := range w.rules {
|
for _, r := range w.rules {
|
||||||
match, err := r.Evaluate(i)
|
res, err := r.Evaluate(i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error evaluating rule: %v", err)
|
log.Printf("error evaluating rule: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !match {
|
if res == nip.RuleResultNoMatch {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package nip
|
|||||||
// These stats are currently NOT supported, rules can not contain them otherwise it will return an error
|
// These stats are currently NOT supported, rules can not contain them otherwise it will return an error
|
||||||
var notSupportedStats = []string{
|
var notSupportedStats = []string{
|
||||||
"plusmindamage",
|
"plusmindamage",
|
||||||
"mindamage",
|
|
||||||
"plusmaxdamage",
|
"plusmaxdamage",
|
||||||
"maxdamage",
|
|
||||||
"enhanceddamage",
|
|
||||||
"itemarmorpercent",
|
"itemarmorpercent",
|
||||||
"itemmindamagepercent",
|
"itemmindamagepercent",
|
||||||
"itemslashdamage",
|
"itemslashdamage",
|
||||||
@@ -19,3 +16,10 @@ var notSupportedStats = []string{
|
|||||||
"secondarymaxdamage",
|
"secondarymaxdamage",
|
||||||
"damagepercent",
|
"damagepercent",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These stats are partially supported, rules can contain them but the ones matching the item type in this list will be blocked
|
||||||
|
var blockedStatsForItemType = map[string][]string{
|
||||||
|
"mindamage": {"axe", "wand", "club", "scepter", "mace", "hammer", "sword", "knife", "thrownweapon", "throwingaxe", "javelin", "spear", "polearm", "staff", "bow", "crossbow", "assassinclaw", "orb", "amazonbow", "amazonspear", "amazonjavelin"},
|
||||||
|
"maxdamage": {"axe", "wand", "club", "scepter", "mace", "hammer", "sword", "knife", "thrownweapon", "throwingaxe", "javelin", "spear", "polearm", "staff", "bow", "crossbow", "assassinclaw", "orb", "amazonbow", "amazonspear", "amazonjavelin"},
|
||||||
|
"enhanceddamage": {"axe", "wand", "club", "scepter", "mace", "hammer", "sword", "knife", "thrownweapon", "throwingaxe", "javelin", "spear", "polearm", "staff", "bow", "crossbow", "assassinclaw", "orb", "amazonbow", "amazonspear", "amazonjavelin"},
|
||||||
|
}
|
||||||
|
|||||||
@@ -156,6 +156,12 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if itemTypes, found := blockedStatsForItemType[statName[0]]; found {
|
||||||
|
if slices.Contains(itemTypes, it.TypeAsString()) {
|
||||||
|
return RuleResultNoMatch, fmt.Errorf("property %s is not supported for item type %s", statName[0], it.TypeAsString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
layer := 0
|
layer := 0
|
||||||
if len(statData) > 1 {
|
if len(statData) > 1 {
|
||||||
layer = statData[1]
|
layer = statData[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user