diff options
| author | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
| commit | abd612c15799f604e671e83dc7c410ed2b44185f (patch) | |
| tree | 0597ca92350de73aac2a7cf26b2f2d6595dac0cc /internal/game/cmd_wear.go | |
| parent | 2725e2927a1595c7b100d942d1f14146252adeb7 (diff) | |
| download | thehouseoficarus-abd612c15799f604e671e83dc7c410ed2b44185f.tar.gz | |
slop refactor
Diffstat (limited to 'internal/game/cmd_wear.go')
| -rw-r--r-- | internal/game/cmd_wear.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/internal/game/cmd_wear.go b/internal/game/cmd_wear.go index 8f8117f..64069bc 100644 --- a/internal/game/cmd_wear.go +++ b/internal/game/cmd_wear.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" + "thehouseoficarus/internal/item" "thehouseoficarus/internal/net" - "thehouseoficarus/internal/object" "thehouseoficarus/internal/player" ) @@ -13,7 +13,7 @@ func (g *Game) executeWear(sess *net.Session, args []string, rawInput string) { g.doWear(sess, strings.Join(args, " ")) } -func (g *Game) checkRequirements(sess *net.Session, p *player.Player, def *object.ItemDef) string { +func (g *Game) checkRequirements(sess *net.Session, p *player.Player, def *item.ItemDef) string { if len(def.Requirements) == 0 { return "" } @@ -85,7 +85,7 @@ func (g *Game) doWear(sess *net.Session, input string) { return } - if def.EquipSlot == object.SlotAmmo && def.Stackable { + if def.EquipSlot == item.SlotAmmo && def.Stackable { g.equipAmmo(sess, p, match.Slot, slot, def, qty) return } @@ -126,13 +126,13 @@ func (g *Game) doWear(sess *net.Session, input string) { sess.WriteLine(fmt.Sprintf("You %s %s.", verb, g.itemColorize(sess, def, match.Name))) } -func (g *Game) equipAmmo(sess *net.Session, p *player.Player, invIdx int, slot *player.InventorySlot, def *object.ItemDef, qty int) { +func (g *Game) equipAmmo(sess *net.Session, p *player.Player, invIdx int, slot *player.InventorySlot, def *item.ItemDef, qty int) { transferQty := slot.Quantity if qty > 0 && qty < transferQty { transferQty = qty } - existingAmmoID, hasAmmo := p.Equipment[object.SlotAmmo] + existingAmmoID, hasAmmo := p.Equipment[item.SlotAmmo] if hasAmmo && existingAmmoID != slot.ItemID { g.unequipAmmo(p) } @@ -146,7 +146,7 @@ func (g *Game) equipAmmo(sess *net.Session, p *player.Player, invIdx int, slot * if hasAmmo && existingAmmoID == slot.ItemID { p.AmmoQty += transferQty } else { - p.Equipment[object.SlotAmmo] = slot.ItemID + p.Equipment[item.SlotAmmo] = slot.ItemID p.AmmoQty = transferQty } @@ -156,7 +156,7 @@ func (g *Game) equipAmmo(sess *net.Session, p *player.Player, invIdx int, slot * } func (g *Game) unequipAmmo(p *player.Player) { - ammoID, ok := p.Equipment[object.SlotAmmo] + ammoID, ok := p.Equipment[item.SlotAmmo] if !ok || p.AmmoQty <= 0 { return } @@ -164,7 +164,7 @@ func (g *Game) unequipAmmo(p *player.Player) { s := p.InvSlot(i) if s != nil && s.ItemID == ammoID { s.Quantity += p.AmmoQty - delete(p.Equipment, object.SlotAmmo) + delete(p.Equipment, item.SlotAmmo) p.AmmoQty = 0 return } @@ -173,7 +173,7 @@ func (g *Game) unequipAmmo(p *player.Player) { if freeSlot >= 0 { p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: ammoID, Quantity: p.AmmoQty}) } - delete(p.Equipment, object.SlotAmmo) + delete(p.Equipment, item.SlotAmmo) p.AmmoQty = 0 } @@ -181,7 +181,7 @@ func (g *Game) doWearAll(sess *net.Session) { p := sess.Player g.cancelAction(p) - bestPerSlot := make(map[object.EquipSlot]struct { + bestPerSlot := make(map[item.EquipSlot]struct { itemID string value int invSlot int @@ -201,7 +201,7 @@ func (g *Game) doWearAll(sess *net.Session) { } current, exists := bestPerSlot[def.EquipSlot] val := def.Value - if def.EquipSlot == object.SlotAmmo && def.Stackable { + if def.EquipSlot == item.SlotAmmo && def.Stackable { val = def.Value * slot.Quantity } if !exists || val > current.value { @@ -221,19 +221,19 @@ func (g *Game) doWearAll(sess *net.Session) { var equipped []string for eqSlot, best := range bestPerSlot { if existing, ok := p.Equipment[eqSlot]; ok && existing == best.itemID { - if eqSlot != object.SlotAmmo { + if eqSlot != item.SlotAmmo { continue } } - if eqSlot == object.SlotAmmo { + if eqSlot == item.SlotAmmo { bestDef, _ := g.ItemStore.Load(best.itemID) if bestDef != nil && bestDef.Stackable { invSlot := p.InvSlot(best.invSlot) if invSlot == nil { continue } - existingID, hasAmmo := p.Equipment[object.SlotAmmo] + existingID, hasAmmo := p.Equipment[item.SlotAmmo] if hasAmmo && existingID != best.itemID { g.unequipAmmo(p) } @@ -242,7 +242,7 @@ func (g *Game) doWearAll(sess *net.Session) { if hasAmmo && existingID == best.itemID { p.AmmoQty += transferQty } else { - p.Equipment[object.SlotAmmo] = best.itemID + p.Equipment[item.SlotAmmo] = best.itemID p.AmmoQty = transferQty } equipped = append(equipped, g.itemColorize(sess, bestDef, bestDef.Name)) |
