aboutsummaryrefslogtreecommitdiff
path: root/internal/player
diff options
context:
space:
mode:
Diffstat (limited to 'internal/player')
-rw-r--r--internal/player/player.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/player/player.go b/internal/player/player.go
index 48c9359..e7d98ac 100644
--- a/internal/player/player.go
+++ b/internal/player/player.go
@@ -338,6 +338,16 @@ func (p *Player) HasItem(itemID string) bool {
return false
}
+func (p *Player) CountItem(itemID string) int {
+ count := 0
+ for _, slot := range p.Inventory {
+ if slot != nil && slot.ItemID == itemID {
+ count += slot.Quantity
+ }
+ }
+ return count
+}
+
func (p *Player) RemoveItem(itemID string, qty int) bool {
remaining := qty
for i, slot := range p.Inventory {