fix test and failed map access

This commit is contained in:
Héctor Giménez
2024-05-05 13:49:47 +09:00
parent 638f3047f8
commit aff05aa9ed
2 changed files with 20 additions and 3 deletions

View File

@@ -156,7 +156,7 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
continue
}
if itemTypes, found := blockedStatsForItemType[statName[0]]; found {
if itemTypes, found := blockedStatsForItemType[statName[1]]; found {
if slices.Contains(itemTypes, it.TypeAsString()) {
return RuleResultNoMatch, fmt.Errorf("property %s is not supported for item type %s", statName[0], it.TypeAsString())
}

View File

@@ -163,6 +163,23 @@ func TestRule_Evaluate(t *testing.T) {
},
want: RuleResultFullMatch,
},
{
name: "enhanceddamage should not work for weapons",
fields: fields{
RawLine: "[type] == axe && [quality] == superior # [enhanceddamage] >= 15 #",
Enabled: true,
},
args: args{
item: data.Item{
Identified: true,
ID: 0,
Name: "handaxe",
Quality: item.QualityUnique,
Stats: []stat.Data{},
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -192,9 +209,9 @@ func TestNew(t *testing.T) {
wantErr bool
}{
{
name: "Enhanced Damage should throw an error",
name: "itemthrustdamage should throw an error",
args: args{
rawRule: "[type] == armor # [enhanceddamage] >= 15",
rawRule: "[type] == axe # [itemthrustdamage] >= 15",
},
wantErr: true,
},