aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_equipment.go
blob: 88bc7f30a1453f1803ff95bf8cbe744358fd22c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package game

import (
	"fmt"

	"thehouseoficarus/internal/item"
	"thehouseoficarus/internal/net"
)

func (g *Game) doEquipment(sess *net.Session) {
	p := sess.Player
	sess.WriteLine("")
	sess.WriteLine("Equipment:")

	for _, slot := range EquipSlots {
		itemID, ok := p.Equipment[slot]
		if !ok {
			sess.WriteLine(fmt.Sprintf("  %-12s (empty)", slot))
			continue
		}
		def, err := g.ItemStore.Load(itemID)
		name := itemID
		if err == nil {
			name = def.Name
		}
		if slot == item.SlotAmmo && p.AmmoQty > 0 {
			sess.WriteLine(fmt.Sprintf("  %-12s %s (x%d)", slot, g.itemColorize(sess, def, name), p.AmmoQty))
		} else {
			sess.WriteLine(fmt.Sprintf("  %-12s %s", slot, g.itemColorize(sess, def, name)))
		}
	}
}