ludic.base's Queue<T> carries a QueueTag (its name and pending count): queue_new(name), q_push(q, v), q_drain(q), q_clear(q) take no BaseState, and core_undrained(tags) names the given queues still holding facts. A reducer on a package's state can now call that package's verbs (wallet_earn(wallet_st, n)). ludic migrate state --prune (ludicc --migrate-prune) takes out each state parameter a function no longer uses, nor anything it calls, and the argument that fills it - including an argument for a parameter the callee has dropped, which is taken out before the call is checked, so a generic's T is told by the argument that says it. A reducer keeps its state. --dry-run now counts the edits it would make. Every package was moved with it: 608 base_st parameters and their arguments, 1889 edits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.7 KiB
Text
70 lines
2.7 KiB
Text
# state.ludic - the port, the numbers a game may change, the facts, and what the fire holds
|
|
# what the fire asks the world. Unbound: this machine runs it, it is dry, there is nothing over
|
|
# it, and there is no ban.
|
|
export port FireWorld {
|
|
owns_world: fn() -> bool = fn fr_yes
|
|
is_wet: fn() -> bool = fn fr_no # rain or snow is falling on the ring
|
|
sheltered: fn() -> bool = fn fr_no # something is over the ring (a tarp)
|
|
allowed: fn() -> bool = fn fr_yes # no fire ban
|
|
}
|
|
function fr_yes() -> bool { return true }
|
|
function fr_no() -> bool { return false }
|
|
|
|
export state FireState {
|
|
fr_light_wood: int = 3 # logs to light one
|
|
fr_light_minutes: float = 120.0 # game minutes of fuel a new fire has
|
|
fr_log_minutes: float = 60.0 # game minutes a log adds
|
|
fr_low_minutes: float = 15.0 # under this, the fire is burning low
|
|
fr_warm_radius: float = 3.6 # metres it warms a body
|
|
fr_cook_radius: float = 3.5 # metres it cooks from
|
|
fr_lit: bool = false
|
|
fr_fuel: float = 0.0 # game minutes left
|
|
fr_rain_h: float = 0.0 # game hours today it burned in the rain under cover
|
|
fr_facts: Queue<FireFact> = null
|
|
}
|
|
|
|
# what lighting or feeding would come to, as the world stands
|
|
export const FIRE_NO_WOOD: int = 0 # not enough to light one
|
|
export const FIRE_NO_LOG: int = 1 # nothing to put on one already lit
|
|
export const FIRE_BANNED: int = 2
|
|
export const FIRE_SOAKED: int = 3 # wet and nothing over the ring
|
|
export const FIRE_LIGHT: int = 4
|
|
export const FIRE_FEED: int = 5
|
|
|
|
# what happened
|
|
export const FIRE_LIT: int = 0
|
|
export const FIRE_WENT_OUT: int = 1
|
|
export const FIRE_LOW_FUEL: int = 2
|
|
|
|
export property FireFact {
|
|
what: int = 0
|
|
fuel: float = 0.0
|
|
}
|
|
|
|
|
|
# the facts, oldest first; the game drains them into its notices
|
|
export function fire_facts(fire_st: mut FireState) -> Queue<FireFact> {
|
|
if fire_st.fr_facts == null { fire_st.fr_facts = queue_new("fire.facts") }
|
|
return fire_st.fr_facts
|
|
}
|
|
|
|
function fr_fact(fire_st: mut FireState, what: int) -> void {
|
|
let f = new FireFact
|
|
f.what = what
|
|
f.fuel = fire_st.fr_fuel
|
|
q_push(fire_facts(fire_st), f)
|
|
}
|
|
|
|
# a game's numbers: logs to light, minutes a new fire and a log are worth, when it is low
|
|
export function fire_config(fire_st: mut FireState, light_wood: int, light_minutes: float, log_minutes: float, low_minutes: float) -> void {
|
|
fire_st.fr_light_wood = light_wood
|
|
fire_st.fr_light_minutes = light_minutes
|
|
fire_st.fr_log_minutes = log_minutes
|
|
fire_st.fr_low_minutes = low_minutes
|
|
}
|
|
|
|
# how far it warms a body and how far it cooks from, in metres
|
|
export function fire_config_reach(fire_st: mut FireState, warm: float, cook: float) -> void {
|
|
fire_st.fr_warm_radius = warm
|
|
fire_st.fr_cook_radius = cook
|
|
}
|