wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -31,67 +31,55 @@ export property ShopVendor {
|
|||
refuses: int = -1
|
||||
}
|
||||
|
||||
export state ShopState {
|
||||
shop_wants_n: int = 3
|
||||
shop_want_mult: float = 1.5
|
||||
shop_glut_mult: float = 0.6
|
||||
shop_week_days: int = 7
|
||||
shop_seed: int = 1013
|
||||
shop_week_rolled: int = -1
|
||||
shop_want_list: []int = null # shop_wants_n per vendor, -1 empty
|
||||
shop_full_list: []int = null # one per vendor, -1 none
|
||||
shop_dice: Rng = null
|
||||
shop_base: []int = null # an item's base price
|
||||
shop_sell_frac: []float = null # what fraction of the curve a vendor pays for it
|
||||
shop_vendor_list: []ShopVendor = null
|
||||
shop_at: int = -1 # the vendor at the counter, -1 none
|
||||
shop_buy_new: float = 1.15
|
||||
shop_buy_best: float = 0.92
|
||||
shop_sell_new: float = 0.62
|
||||
shop_sell_best: float = 0.85
|
||||
shop_trade_q: Queue<ShopTrade> = null
|
||||
}
|
||||
var shop_base: []int = null # an item's base price
|
||||
var shop_sell_frac: []float = null # what fraction of the curve a vendor pays for it
|
||||
var shop_vendor_list: []ShopVendor = null
|
||||
var shop_at: int = -1 # the vendor at the counter, -1 none
|
||||
|
||||
# the curve: buying from `buy_new` of base at rep 0 down to `buy_best` at 100; selling the same way
|
||||
var shop_buy_new: float = 1.15
|
||||
var shop_buy_best: float = 0.92
|
||||
var shop_sell_new: float = 0.62
|
||||
var shop_sell_best: float = 0.85
|
||||
|
||||
# the items: a base price and a sell fraction each (raw material pays less than something made)
|
||||
export function shop_config_items(shop_st: mut ShopState, prices: []int, sell: []float) -> void {
|
||||
shop_st.shop_base = prices
|
||||
shop_st.shop_sell_frac = sell
|
||||
export function shop_config_items(prices: []int, sell: []float) -> void {
|
||||
shop_base = prices
|
||||
shop_sell_frac = sell
|
||||
}
|
||||
|
||||
export function shop_config_curve(shop_st: mut ShopState, buy_new: float, buy_best: float, sell_new: float, sell_best: float) -> void {
|
||||
shop_st.shop_buy_new = buy_new
|
||||
shop_st.shop_buy_best = buy_best
|
||||
shop_st.shop_sell_new = sell_new
|
||||
shop_st.shop_sell_best = sell_best
|
||||
export function shop_config_curve(buy_new: float, buy_best: float, sell_new: float, sell_best: float) -> void {
|
||||
shop_buy_new = buy_new
|
||||
shop_buy_best = buy_best
|
||||
shop_sell_new = sell_new
|
||||
shop_sell_best = sell_best
|
||||
}
|
||||
|
||||
export function shop_clear_vendors(shop_st: mut ShopState) -> void { shop_st.shop_vendor_list = new []ShopVendor }
|
||||
export function shop_clear_vendors() -> void { shop_vendor_list = new []ShopVendor }
|
||||
|
||||
# a vendor; its number is the order added
|
||||
export function shop_add_vendor(shop_st: mut ShopState, stock: []int, buys: []int, refuses: int) -> int {
|
||||
if shop_st.shop_vendor_list == null { shop_clear_vendors(shop_st) }
|
||||
export function shop_add_vendor(stock: []int, buys: []int, refuses: int) -> int {
|
||||
if shop_vendor_list == null { shop_clear_vendors() }
|
||||
let v = new ShopVendor
|
||||
v.stock = stock
|
||||
v.buys = buys
|
||||
v.refuses = refuses
|
||||
push(shop_st.shop_vendor_list, v)
|
||||
return len(shop_st.shop_vendor_list) - 1
|
||||
push(shop_vendor_list, v)
|
||||
return len(shop_vendor_list) - 1
|
||||
}
|
||||
|
||||
export function shop_vendors(shop_st: ShopState) -> int {
|
||||
if shop_st.shop_vendor_list == null { return 0 }
|
||||
return len(shop_st.shop_vendor_list)
|
||||
export function shop_vendors() -> int {
|
||||
if shop_vendor_list == null { return 0 }
|
||||
return len(shop_vendor_list)
|
||||
}
|
||||
|
||||
export function shop_items(shop_st: ShopState) -> int {
|
||||
if shop_st.shop_base == null { return 0 }
|
||||
return len(shop_st.shop_base)
|
||||
export function shop_items() -> int {
|
||||
if shop_base == null { return 0 }
|
||||
return len(shop_base)
|
||||
}
|
||||
|
||||
export function shop_vendor_ok(shop_st: ShopState, v: int) -> bool { return v >= 0 and v < shop_vendors(shop_st) }
|
||||
export function shop_item_ok(shop_st: ShopState, it: int) -> bool { return it >= 0 and it < shop_items(shop_st) }
|
||||
export function shop_vendor_ok(v: int) -> bool { return v >= 0 and v < shop_vendors() }
|
||||
export function shop_item_ok(it: int) -> bool { return it >= 0 and it < shop_items() }
|
||||
|
||||
export const SHOP_BOUGHT: int = 0
|
||||
export const SHOP_SOLD: int = 1
|
||||
|
|
@ -105,8 +93,9 @@ export property ShopTrade {
|
|||
price: int = 0
|
||||
}
|
||||
|
||||
var shop_trade_q: Queue<ShopTrade> = null
|
||||
|
||||
export function shop_trades(base_st: mut BaseState, shop_st: mut ShopState) -> Queue<ShopTrade> {
|
||||
if shop_st.shop_trade_q == null { shop_st.shop_trade_q = queue_new(base_st, "shop.trades") }
|
||||
return shop_st.shop_trade_q
|
||||
export function shop_trades() -> Queue<ShopTrade> {
|
||||
if shop_trade_q == null { shop_trade_q = queue_new("shop.trades") }
|
||||
return shop_trade_q
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue