- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`) - ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk" for every build stat); Stats.base uses stats_field_name - ludic.shooter: compare aim modes and fire patterns with AimMode.* and WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y - ludic.npcai: DecisionMade / brain_set_state use AiState.* - examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and BACKDROP named; strings.ludic header says what it prints - whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only), `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every ```ludic fence reformatted with the fixed formatter (whitespace only) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
33 lines
1.6 KiB
Text
33 lines
1.6 KiB
Text
# net_roles.ludic — N5: handler roles + the drivable sim (NETWORKING-DESIGN §6.2,
|
|
# §5, §13 N5).
|
|
#
|
|
# A handler's network role is a declarative annotation, never a runtime branch in
|
|
# ordinary code:
|
|
# (unmarked) runs on every peer — the shared, deterministic simulation
|
|
# @Server runs only on the authority (clients get the result via @Sync)
|
|
# @Predicted runs on the owning client and the server (auto-reconciled)
|
|
# The runtime sets the peer's role register (set_role); offline it defaults to
|
|
# server, so guards collapse to "run here" and a non-networked build is unchanged.
|
|
#
|
|
# The per-frame phases are also exposed as callables — tick_fixed() runs the sim
|
|
# phases — so this game owns its own loop via `entry` (for prediction/rollback,
|
|
# replay, headless tests). Acting as a client then the server: 1, then 102.
|
|
program NetRoles {
|
|
property Score { n: int = 0 }
|
|
model Board { Score }
|
|
|
|
handler Both phase Update { for (Score) in query [Score] { Score.n += 1 } } # runs everywhere
|
|
@Server handler ServerOnly phase Update { for (Score) in query [Score] { Score.n += 100 } } # authority only
|
|
|
|
entry {
|
|
spawn Board { Score { n: 0 } }
|
|
|
|
set_role(0) # act as a client
|
|
tick_fixed() # Both(+1); ServerOnly skipped
|
|
for (Score) in query [Score] { print(Score.n) } # 1
|
|
|
|
set_role(1) # act as the server
|
|
tick_fixed() # Both(+1) + ServerOnly(+100)
|
|
for (Score) in query [Score] { print(Score.n) } # 102
|
|
}
|
|
}
|