basic item filter wip

This commit is contained in:
Héctor Giménez
2023-03-12 19:32:50 +09:00
parent 306150e873
commit 66dd506ba7
12 changed files with 273 additions and 26 deletions

View File

@@ -3,16 +3,20 @@ package item
type Quality int
const (
QualityNormal Quality = 0x02
QualitySuperior Quality = 0x03
QualityMagic Quality = 0x04
QualitySet Quality = 0x05
QualityRare Quality = 0x06
QualityUnique Quality = 0x07
QualityLowQuality Quality = 0x01
QualityNormal Quality = 0x02
QualitySuperior Quality = 0x03
QualityMagic Quality = 0x04
QualitySet Quality = 0x05
QualityRare Quality = 0x06
QualityUnique Quality = 0x07
QualityCrafted Quality = 0x08
)
func (q Quality) ToString() string {
switch q {
case QualityLowQuality:
return "LowQuality"
case QualityNormal:
return "Normal"
case QualitySuperior:

View File

@@ -2,7 +2,7 @@ package item
import "strings"
var classMapping = map[string][]string{
var typeMapping = map[string][]string{
"Axes": {"HandAxe", "Axe", "DoubleAxe", "MilitaryPick", "WarAxe", "LargeAxe", "BroadAxe", "BattleAxe", "GreatAxe", "GiantAxe", "Hatchet", "Cleaver", "TwinAxe", "Crowbill", "Naga", "MilitaryAxe", "BeardedAxe", "Tabar", "GothicAxe", "AncientAxe", "Tomahawk", "SmallCrescent", "EttinAxe", "WarSpike", "BerserkerAxe", "FeralAxe", "SilverEdgedAxe", "Decapitator", "ChampionAxe", "GloriousAxe"},
"Wands": {"Wand", "YewWand", "BoneWand", "GrimWand", "BurntWand", "PetrifiedWand", "TombWand", "GraveWand", "PolishedWand", "GhostWand", "LichWand", "UnearthedWand"},
"Clubs": {"Club", "SpikedClub", "Cudgel", "BarbedClub", "Truncheon", "TyrantClub"},
@@ -37,21 +37,11 @@ var classMapping = map[string][]string{
"NecromancerShields": {"PreservedHead", "ZombieHead", "UnravellerHead", "GargoyleHead", "DemonHeadShield", "MummifiedTrophy", "FetishTrophy", "SextonTrophy", "CantorTrophy", "HierophantTrophy", "MinionSkull", "HellspawnSkull", "OverseerSkull", "SuccubusSkull", "BloodlordSkull"},
}
func IsClass(itemClass string) bool {
for class := range classMapping {
if strings.EqualFold(itemClass, class) {
return true
}
}
return false
}
func ClassForItemName(itemName string) (string, bool) {
for class, itemNames := range classMapping {
func TypeForItemName(itemName string) (string, bool) {
for t, itemNames := range typeMapping {
for _, name := range itemNames {
if strings.EqualFold(itemName, name) {
return class, true
return t, true
}
}
}

View File

@@ -1,9 +1,10 @@
package data
import (
"strings"
"github.com/hectorgimenez/d2go/pkg/data/item"
"github.com/hectorgimenez/d2go/pkg/data/stat"
"strings"
)
type Items struct {
@@ -29,6 +30,12 @@ type Item struct {
IsVendor bool
}
func (i Item) Type() string {
t, _ := item.TypeForItemName(string(i.Name))
return t
}
func (i Item) IsPotion() bool {
return i.IsHealingPotion() || i.IsManaPotion() || i.IsRejuvPotion()
}