aboutsummaryrefslogtreecommitdiff
path: root/internal/behavior/behavior.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-01 18:36:21 -0400
committerhistoria <[not public]>2026-07-01 18:36:21 -0400
commit78b522d57a9ebc691e075523910d7cdaa06b6493 (patch)
treeb2a68397e0cecc5abb56e5ae451c05a9435cc5fe /internal/behavior/behavior.go
parente6b4cb9f5816c6ee239233bc85f74ee446a161c2 (diff)
downloadthehouseoficarus-78b522d57a9ebc691e075523910d7cdaa06b6493.tar.gz
feat: shop system removed from talk system, added per-item restock and variable pricing
Diffstat (limited to 'internal/behavior/behavior.go')
-rw-r--r--internal/behavior/behavior.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/behavior/behavior.go b/internal/behavior/behavior.go
index 646495a..06e2715 100644
--- a/internal/behavior/behavior.go
+++ b/internal/behavior/behavior.go
@@ -66,7 +66,6 @@ type ShopConfig struct {
Message string `yaml:"message"`
BuyPercentage float64 `yaml:"buy_percentage"` // sell price at zero stock, % of value (default 40)
ChangePercentage float64 `yaml:"change_percentage"` // sell price drop per unit of stock, % of value (default 3)
- RestockTicks float64 `yaml:"restock_ticks"` // shop-wide default restock interval
BuysAnything *bool `yaml:"buys_anything"` // buy items not in the list (default true)
Items []ShopItem `yaml:"items"`
}
@@ -82,9 +81,14 @@ const (
ShopBuyPercentage = 40.0
ShopChangePercentage = 3.0
ShopMinSellPercent = 10.0
- ShopDefaultRestock = 100.0
)
+// ShopDefaultRestock is the fallback restock interval (in ticks) for a shop item
+// that does not set its own restock_ticks. It is configurable via
+// game_constants.shop_default_restock in config.yaml (wired up at startup); the
+// value here is only the default used when no config is loaded.
+var ShopDefaultRestock = 1000.0
+
// EffectiveBuyPercentage returns BuyPercentage or the default.
func (c *ShopConfig) EffectiveBuyPercentage() float64 {
if c.BuyPercentage > 0 {
@@ -120,14 +124,11 @@ func (c *ShopConfig) SellPrice(value, stock int) int {
}
// RestockInterval returns the effective restock interval (in ticks) for an item,
-// honoring the per-item override, then the shop default, then the global default.
+// honoring the per-item override, then the configurable global default.
func (c *ShopConfig) RestockInterval(item *ShopItem) int {
if item != nil && item.RestockTicks > 0 {
return int(item.RestockTicks)
}
- if c.RestockTicks > 0 {
- return int(c.RestockTicks)
- }
return int(ShopDefaultRestock)
}