wip(0.S3): the packages migrated by ludic migrate state packages - every package test green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e8b5b0523
commit
07505e7ef2
294 changed files with 14996 additions and 14675 deletions
|
|
@ -1,75 +1,75 @@
|
|||
# run.ludic - the sky moving on. Only the machine that owns the world runs the spells; every
|
||||
# machine eases the ground's wetness and makes its own lightning out of a storm it is told of.
|
||||
function wx_turn() -> void {
|
||||
let was = wx_state
|
||||
wx_state = wx_next
|
||||
wx_next = wx_pick_next(wx_state)
|
||||
wx_left = wx_spell_hours(wx_state)
|
||||
if wx_forced {
|
||||
wx_forced = false
|
||||
function wx_turn(base_st: mut BaseState, weather_st: mut WeatherState) -> void {
|
||||
let was = weather_st.wx_state
|
||||
weather_st.wx_state = weather_st.wx_next
|
||||
weather_st.wx_next = wx_pick_next(weather_st, weather_st.wx_state)
|
||||
weather_st.wx_left = wx_spell_hours(weather_st, weather_st.wx_state)
|
||||
if weather_st.wx_forced {
|
||||
weather_st.wx_forced = false
|
||||
let least = Math.max(5.0, WeatherWorld.front_hours())
|
||||
if wx_left < least { wx_left = least }
|
||||
if weather_st.wx_left < least { weather_st.wx_left = least }
|
||||
}
|
||||
if wx_state == was { return }
|
||||
if weather_st.wx_state == was { return }
|
||||
# a front going through and leaving clear sky behind it: the light people get up for
|
||||
if wx_kinds[wx_state].clear and wx_kinds[was].wet and not wx_night() {
|
||||
wx_clear_t = 0.6
|
||||
wx_fact(WEATHER_CLEARED, wx_state, was)
|
||||
if weather_st.wx_kinds[weather_st.wx_state].clear and weather_st.wx_kinds[was].wet and not wx_night() {
|
||||
weather_st.wx_clear_t = 0.6
|
||||
wx_fact(base_st, weather_st, WEATHER_CLEARED, weather_st.wx_state, was)
|
||||
}
|
||||
wx_fact(WEATHER_BEGAN, wx_state, was)
|
||||
wx_fact(base_st, weather_st, WEATHER_BEGAN, weather_st.wx_state, was)
|
||||
}
|
||||
|
||||
function wx_wind_tick(dt: float) -> void {
|
||||
let kd = wx_kinds[wx_state]
|
||||
wx_wind = wx_wind + (kd.wind - wx_wind) * Math.min(1.0, dt * 0.3)
|
||||
function wx_wind_tick(weather_st: mut WeatherState, dt: float) -> void {
|
||||
let kd = weather_st.wx_kinds[weather_st.wx_state]
|
||||
weather_st.wx_wind = weather_st.wx_wind + (kd.wind - weather_st.wx_wind) * Math.min(1.0, dt * 0.3)
|
||||
var want = kd.wind_dir
|
||||
if want < 0.0 {
|
||||
let h = wx_hours()
|
||||
want = wx_down_dir
|
||||
if h > wx_up_from and h < wx_up_to { want = wx_up_dir }
|
||||
want = weather_st.wx_down_dir
|
||||
if h > weather_st.wx_up_from and h < weather_st.wx_up_to { want = weather_st.wx_up_dir }
|
||||
}
|
||||
let r = dt * 0.12
|
||||
wx_dir = wx_wrap(wx_dir + Math.clamp(wx_wrap(want - wx_dir), -r, r))
|
||||
weather_st.wx_dir = wx_wrap(weather_st.wx_dir + Math.clamp(wx_wrap(want - weather_st.wx_dir), -r, r))
|
||||
}
|
||||
|
||||
# the spells: the story's lean, the clock running down, the edges eased, the wind
|
||||
function wx_spells(dt: float, gh: float) -> void {
|
||||
wx_apply_bias()
|
||||
wx_left = wx_left - gh
|
||||
if wx_left < 0.0 { wx_turn() }
|
||||
function wx_spells(base_st: mut BaseState, weather_st: mut WeatherState, dt: float, gh: float) -> void {
|
||||
wx_apply_bias(base_st, weather_st)
|
||||
weather_st.wx_left = weather_st.wx_left - gh
|
||||
if weather_st.wx_left < 0.0 { wx_turn(base_st, weather_st) }
|
||||
var want = 1.0
|
||||
if wx_kinds[wx_state].clear { want = 0.0 }
|
||||
if wx_left < 0.5 and wx_kinds[wx_next].clear { want = 0.0 }
|
||||
wx_amount = wx_amount + (want - wx_amount) * Math.min(1.0, dt * 0.5)
|
||||
wx_wind_tick(dt)
|
||||
if wx_clear_t > 0.0 { wx_clear_t = wx_clear_t - gh }
|
||||
if weather_st.wx_kinds[weather_st.wx_state].clear { want = 0.0 }
|
||||
if weather_st.wx_left < 0.5 and weather_st.wx_kinds[weather_st.wx_next].clear { want = 0.0 }
|
||||
weather_st.wx_amount = weather_st.wx_amount + (want - weather_st.wx_amount) * Math.min(1.0, dt * 0.5)
|
||||
wx_wind_tick(weather_st, dt)
|
||||
if weather_st.wx_clear_t > 0.0 { weather_st.wx_clear_t = weather_st.wx_clear_t - gh }
|
||||
}
|
||||
|
||||
# soaking is faster than drying: a downpour wets the ground in under a minute, and it takes
|
||||
# several to give it back
|
||||
function wx_ground_tick(dt: float) -> void {
|
||||
let want = wx_kinds[wx_state].soak * wx_amount
|
||||
function wx_ground_tick(weather_st: mut WeatherState, dt: float) -> void {
|
||||
let want = weather_st.wx_kinds[weather_st.wx_state].soak * weather_st.wx_amount
|
||||
var k = dt * 0.10
|
||||
if want < wx_ground { k = dt * 0.020 }
|
||||
wx_ground = wx_ground + (want - wx_ground) * Math.clamp(k, 0.0, 1.0)
|
||||
if want < weather_st.wx_ground { k = dt * 0.020 }
|
||||
weather_st.wx_ground = weather_st.wx_ground + (want - weather_st.wx_ground) * Math.clamp(k, 0.0, 1.0)
|
||||
}
|
||||
|
||||
function wx_storm_tick(dt: float) -> void {
|
||||
wx_flash = wx_flash * Math.max(0.0, 1.0 - dt * 9.0)
|
||||
if not wx_kinds[wx_state].thunder or wx_amount < 0.5 { return }
|
||||
wx_thunder_t = wx_thunder_t - dt
|
||||
if wx_thunder_t < 0.0 {
|
||||
wx_thunder_t = rng_span(wx_dice, 9.0, 34.0)
|
||||
wx_flash = 1.0
|
||||
wx_fact(WEATHER_THUNDER, wx_state, wx_state)
|
||||
function wx_storm_tick(base_st: mut BaseState, weather_st: mut WeatherState, dt: float) -> void {
|
||||
weather_st.wx_flash = weather_st.wx_flash * Math.max(0.0, 1.0 - dt * 9.0)
|
||||
if not weather_st.wx_kinds[weather_st.wx_state].thunder or weather_st.wx_amount < 0.5 { return }
|
||||
weather_st.wx_thunder_t = weather_st.wx_thunder_t - dt
|
||||
if weather_st.wx_thunder_t < 0.0 {
|
||||
weather_st.wx_thunder_t = rng_span(weather_st.wx_dice, 9.0, 34.0)
|
||||
weather_st.wx_flash = 1.0
|
||||
wx_fact(base_st, weather_st, WEATHER_THUNDER, weather_st.wx_state, weather_st.wx_state)
|
||||
}
|
||||
}
|
||||
|
||||
# one step: `dt` real seconds and `gh` game hours
|
||||
export function weather_run(dt: float, gh: float) -> void {
|
||||
if weather_kind_count() == 0 { return }
|
||||
if wx_owns() { wx_spells(dt, gh) }
|
||||
wx_ground_tick(dt)
|
||||
wx_storm_tick(dt)
|
||||
if weather_wet() { wx_wet_today = true }
|
||||
export function weather_run(base_st: mut BaseState, weather_st: mut WeatherState, dt: float, gh: float) -> void {
|
||||
if weather_kind_count(weather_st) == 0 { return }
|
||||
if wx_owns() { wx_spells(base_st, weather_st, dt, gh) }
|
||||
wx_ground_tick(weather_st, dt)
|
||||
wx_storm_tick(base_st, weather_st, dt)
|
||||
if weather_wet(weather_st) { weather_st.wx_wet_today = true }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue