Add data structures, it requires tons of refactor but it's more or less working

This commit is contained in:
Héctor Giménez
2023-03-11 21:28:33 +09:00
parent 73978a702c
commit 8600c2e2f6
17 changed files with 4383 additions and 0 deletions

45
pkg/data/items.go Normal file
View File

@@ -0,0 +1,45 @@
package game
import (
"github.com/hectorgimenez/d2go/pkg/data/item"
"github.com/hectorgimenez/d2go/pkg/data/stat"
"strings"
)
type Items struct {
Belt Belt
Inventory Inventory
Shop []Item
Ground []Item
Equipped []Item
}
type Inventory []Item
type UnitID int
type Item struct {
UnitID
Name item.Name
Quality item.Quality
Position Position
Ethereal bool
IsHovered bool
Stats map[stat.Stat]int
Identified bool
IsVendor bool
}
func (i Item) IsPotion() bool {
return i.IsHealingPotion() || i.IsManaPotion() || i.IsRejuvPotion()
}
func (i Item) IsHealingPotion() bool {
return strings.Contains(string(i.Name), string(HealingPotion))
}
func (i Item) IsManaPotion() bool {
return strings.Contains(string(i.Name), string(ManaPotion))
}
func (i Item) IsRejuvPotion() bool {
return strings.Contains(string(i.Name), string(RejuvenationPotion))
}