ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.8 KiB
Text
70 lines
2.8 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(base_st: mut BaseState, fire_st: mut FireState) -> Queue<FireFact> {
|
|
if fire_st.fr_facts == null { fire_st.fr_facts = queue_new(base_st, "fire.facts") }
|
|
return fire_st.fr_facts
|
|
}
|
|
|
|
function fr_fact(base_st: mut BaseState, fire_st: mut FireState, what: int) -> void {
|
|
let f = new FireFact
|
|
f.what = what
|
|
f.fuel = fire_st.fr_fuel
|
|
q_push(base_st, fire_facts(base_st, 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
|
|
}
|