refactor(packages): the mechanic packages use ludic_base only, and ask through ports

ludic.clock, .effects, .inventory, .wallet, .weather and .tracks say
'uses ludic_base' (ludic.base uses nothing). ClockWorld, PackRules,
WeatherWorld and TracksWorld are export ports whose defaults are the old
fallbacks; clock_bind, inv_bind, weather_bind and tracks_bind are gone,
and the tests bind their fakes. The base README's toy does the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 05:36:11 +03:00
parent f4062010e9
commit 63e29f024c
31 changed files with 130 additions and 149 deletions

View file

@ -7,6 +7,7 @@ program RouteTest {
numbers float
function water_everywhere_but_land(x: float, z: float) -> bool { return x < 100.0 }
bind FishingWorld { is_water: fn water_everywhere_but_land }
# the route: a landed fish goes into the pack
function route_fishing_pack(t: Tick) -> void {
@ -16,9 +17,6 @@ program RouteTest {
function game_start() -> void {
core_clear()
let w = new FishingWorld
w.is_water = fn water_everywhere_but_land
fishing_bind(w)
core_add(fishing_system())
let r = system_new("route.fishing_pack", PH_RESOLVE)
r.tick = fn route_fishing_pack

View file

@ -1,16 +1,14 @@
# a toy mechanic: casting a line. It uses ludic.base and nothing else.
module toy_fishing
module toy_fishing uses ludic_base
numbers float
import "ludic.base"
export property Caught { species: int = 0, weight: float = 0.0 }
export property FishingWorld { is_water: fn(float, float) -> bool = null } # its port
var world: FishingWorld = null
export port FishingWorld { is_water: fn(float, float) -> bool } # its port
var dice: Rng = null
var casts: int = 0
export var caught: Queue<Caught> = null # its facts
export function fishing_bind(w: FishingWorld) -> void { world = w }
export function fishing_cast(x: float, z: float) -> bool { # its verb
if not world.is_water(x, z) { return false }
if not FishingWorld.is_water(x, z) { return false }
casts += 1
return true
}

View file

@ -1,5 +1,5 @@
# a toy mechanic: a pack of counts by kind, saved in its own section
module toy_pack
module toy_pack uses ludic_base
numbers float
import "ludic.base"
var counts: []int = null