aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_wear.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 02:18:53 -0400
committerhistoria <[not public]>2026-06-19 02:18:53 -0400
commit86aec0e14eb6fec0a39d742bab1761dad8d7012c (patch)
treeaa0d9511c73ed86ffebc5de5ab862a62afd730f8 /internal/game/cmd_wear.go
parent458916fb78dcef3ff77cb29b7ba98d9f646819fc (diff)
downloadthehouseoficarus-86aec0e14eb6fec0a39d742bab1761dad8d7012c.tar.gz
feat: hostile mobs, equipment prereqs
Diffstat (limited to 'internal/game/cmd_wear.go')
-rw-r--r--internal/game/cmd_wear.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/game/cmd_wear.go b/internal/game/cmd_wear.go
index ddc970b..692a3e4 100644
--- a/internal/game/cmd_wear.go
+++ b/internal/game/cmd_wear.go
@@ -9,6 +9,22 @@ import (
"thehouseoficarus/internal/player"
)
+func (g *Game) checkRequirements(p *player.Player, def *object.ItemDef) string {
+ if len(def.Requirements) == 0 {
+ return ""
+ }
+ var unmet []string
+ for skill, level := range def.Requirements {
+ if p.Level(player.SkillName(skill)) < level {
+ unmet = append(unmet, fmt.Sprintf("%d %s", level, skill))
+ }
+ }
+ if len(unmet) == 0 {
+ return ""
+ }
+ return fmt.Sprintf("You need %s to wear %s.", strings.Join(unmet, ", "), def.Name)
+}
+
func (g *Game) doWear(sess *net.Session, input string) {
p := sess.Player.(*player.Player)
@@ -54,6 +70,11 @@ func (g *Game) doWear(sess *net.Session, input string) {
return
}
+ if msg := g.checkRequirements(p, def); msg != "" {
+ sess.WriteLine(msg)
+ return
+ }
+
if def.EquipSlot == object.SlotAmmo && def.Stackable {
g.equipAmmo(sess, p, match.Slot, slot, def, qty)
return
@@ -165,6 +186,9 @@ func (g *Game) doWearAll(sess *net.Session) {
if err != nil || def.EquipSlot == "" {
continue
}
+ if g.checkRequirements(p, def) != "" {
+ continue
+ }
current, exists := bestPerSlot[def.EquipSlot]
val := def.Value
if def.EquipSlot == object.SlotAmmo && def.Stackable {