From 86aec0e14eb6fec0a39d742bab1761dad8d7012c Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 19 Jun 2026 02:18:53 -0400 Subject: feat: hostile mobs, equipment prereqs --- internal/game/cmd_wear.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'internal/game/cmd_wear.go') 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 { -- cgit v1.2.3