NIP parser v2 (#17)

This commit is contained in:
Héctor Giménez
2024-05-05 12:15:08 +09:00
committed by GitHub
parent 0d5c108721
commit bb0ec2555d
28 changed files with 56618 additions and 1385 deletions

View File

@@ -48,6 +48,7 @@ func (i Items) ByLocation(locations ...item.Location) []Item {
type UnitID int
type Item struct {
ID int
UnitID
Name item.Name
Quality item.Quality
@@ -55,11 +56,17 @@ type Item struct {
Location item.Location
Ethereal bool
IsHovered bool
Stats map[stat.ID]stat.Data
Stats []stat.Data
BaseStats []stat.Data
Identified bool
Type int
}
func (i Item) Type() string {
func (i Item) Desc() item.Description {
return item.Desc[i.ID]
}
func (i Item) TypeAsString() string {
t, _ := item.TypeForItemName(string(i.Name))
return t
@@ -90,3 +97,14 @@ func (i Item) IsFromQuest() bool {
return false
}
func (i Item) FindStat(id stat.ID, layer int) (stat.Data, bool) {
totalStats := append(i.Stats, i.BaseStats...)
for _, s := range totalStats {
if s.ID == id && s.Layer == layer {
return s, true
}
}
return stat.Data{}, false
}