Roll and Race: Board Tracks, Spaces and Pawns Kit
README.md
boardKit.rules
The pure race rules model behind every boardKit board: no entities and no network, so it runs in tests and anywhere else. Rules.new({ track, layout, seats, finish, mode, forkChoice, cards, turns, coins, seed, hooks, ctx }) makes a game; g:move(seat, n) walks a pawn, pauses at a fork for g:choose(seat, option) when forkChoice = "player", lands, applies the space (boost, back, skip, card, again, swap, warp, ladder, slide, toll, bonus), checks the finish (overshoot, exact or bounce) and passes the turn, skipping seats that miss a turn or are not playing. Every change is an event in g.events (turn, move, moved, landed, boost, back, skipNext, skip, drawCard, again, swap, warp, ladder, slide, toll, bonus, choice, chose, blocked, refused, finished, won, over). g:snapshot() / g:load(snap) save and restore it; g:standings() and g:leader() rank the seats.
Rule hooks, each called with (ctx, seat, ...): canMove(ctx, seat, n, g) returns false, "reason" to refuse; onLand(ctx, seat, space, g) returns false to cancel the space's own effect; onCard(ctx, seat, card, g) the same for a fortune card; onTurn, onWin, onMove(ctx, seat, path, g). Effects that move a pawn do not chain.