From 78b522d57a9ebc691e075523910d7cdaa06b6493 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 1 Jul 2026 18:36:21 -0400 Subject: feat: shop system removed from talk system, added per-item restock and variable pricing --- internal/behavior/behavior.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'internal/behavior/behavior.go') 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) } -- cgit v1.2.3