aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_shop.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-25 15:40:48 -0400
committerhistoria <[not public]>2026-06-25 15:40:48 -0400
commitabd612c15799f604e671e83dc7c410ed2b44185f (patch)
tree0597ca92350de73aac2a7cf26b2f2d6595dac0cc /internal/game/cmd_shop.go
parent2725e2927a1595c7b100d942d1f14146252adeb7 (diff)
downloadthehouseoficarus-abd612c15799f604e671e83dc7c410ed2b44185f.tar.gz
slop refactor
Diffstat (limited to 'internal/game/cmd_shop.go')
-rw-r--r--internal/game/cmd_shop.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/internal/game/cmd_shop.go b/internal/game/cmd_shop.go
index b293ff9..51d0ab1 100644
--- a/internal/game/cmd_shop.go
+++ b/internal/game/cmd_shop.go
@@ -5,9 +5,10 @@ import (
"strconv"
"strings"
- "thehouseoficarus/internal/action"
+ "thehouseoficarus/internal/behavior"
+ "thehouseoficarus/internal/item"
"thehouseoficarus/internal/net"
- "thehouseoficarus/internal/object"
+ "thehouseoficarus/internal/ui"
)
func (g *Game) handleShopInput(sess *net.Session, input string) {
@@ -90,15 +91,15 @@ func (g *Game) writeShopPrompt(sess *net.Session) {
sess.Write(fmt.Sprintf("\n%s", g.colorize(sess, "dialog", "> ")))
}
-func (g *Game) shopConfig(sess *net.Session) *action.ShopConfig {
+func (g *Game) shopConfig(sess *net.Session) *behavior.ShopConfig {
cfg := sess.Shop
return cfg
}
type shopMatch struct {
- si *action.ShopItem
+ si *behavior.ShopItem
name string
- def *object.ItemDef
+ def *item.ItemDef
}
func (g *Game) showShopBrowse(sess *net.Session) {
@@ -121,7 +122,7 @@ func (g *Game) showShopBrowse(sess *net.Session) {
unicode = p.OptionBool("unicode")
}
- t := Table{
+ t := ui.Table{
Title: "Shop Inventory",
Columns: []string{"Item", "Buy Price", "Sell Price"},
}
@@ -149,7 +150,7 @@ func (g *Game) showShopBrowse(sess *net.Session) {
}
}
-func (g *Game) findShopMatches(input string, cfg *action.ShopConfig) []shopMatch {
+func (g *Game) findShopMatches(input string, cfg *behavior.ShopConfig) []shopMatch {
var matches []shopMatch
for i := range cfg.Items {
si := &cfg.Items[i]
@@ -158,7 +159,7 @@ func (g *Game) findShopMatches(input string, cfg *action.ShopConfig) []shopMatch
if def != nil {
itemName = def.Name
}
- if object.WordPrefixMatch(input, itemName) {
+ if behavior.WordPrefixMatch(input, itemName) {
matches = append(matches, shopMatch{si: si, name: itemName, def: def})
}
}
@@ -216,7 +217,7 @@ func (g *Game) doShopBuy(sess *net.Session, input string, qty int, all bool) {
g.buyShopItem(sess, *si, actualQty)
}
-func (g *Game) buyShopItem(sess *net.Session, si action.ShopItem, qty int) {
+func (g *Game) buyShopItem(sess *net.Session, si behavior.ShopItem, qty int) {
p := sess.Player
totalCost := si.BuyPrice * qty
@@ -334,7 +335,7 @@ func (g *Game) doShopSell(sess *net.Session, input string, qty int, all bool) {
match := matches[0]
- var shopItem *action.ShopItem
+ var shopItem *behavior.ShopItem
for i := range cfg.Items {
si := &cfg.Items[i]
if si.ItemID == match.ID && si.SellPrice > 0 {
@@ -393,7 +394,7 @@ func (g *Game) leaveShop(sess *net.Session) {
return
}
- td, ok := p.Action.Data.(*action.TalkData)
+ td, ok := p.Action.Data.(*behavior.TalkData)
if !ok || td.Cfg == nil {
sess.State = net.StateGame
g.cancelAction(p)