Log inGet started
Package

OrigoMatch.component

Newest version

README.md

OrigoMatch

Origo Party's referee and turn engine. Attaches to the scene's empty Match anchor (mounted by scenes/main.scene/entrypoint.luau with no data) and boots itself in start().

It is the only writer of Rules.state. It publishes the live state table (Rules.newState()), runs the whole match machine —

title → round → per-turn (roll → move → resolve) → round close → COIN CLASH → ceremony

— for the CPU brains on seats 2–4, the shop stock and buying, the Star purchase (20 coins, taken on passing or landing on the Star Space, or bought from the shop), and the final ranking. A round is three laps of the turn order, so every seat lands nine times across the match. Every beat is written to Rules.state (with state.seq bumped) and announced on the Rules bus; no subscriber is needed for the match to advance.

Sibling components it expects

None are required. The slices are readers:

  • OrigoBoard — pawns, die, camera; reads state.players[i].tile and the roll / moveStep / arrive / resolve events.
  • OrigoHud — screens; reads state.phase, state.round, state.turnSeat, state.die, state.shop, state.rankings and the hud events.
  • OrigoShowdown — COIN CLASH; answers showdownStart { seconds } with showdownScore { seat, grabs } and showdownEnd { results }. If no arena answers within 1.5 s the referee simulates the grabs itself and still closes the round, so the match never stalls on a missing slice.
  • OrigoSound — subscribes to the bus only.

Driving it

  • The clock is its own. update(dt) advances a match clock and paces the coroutine that is the match script, so a hot-seat turn always finishes without input.
  • Early commit. Rules.emit("commit") (payload optional: { seat }) fast-forwards the rest of the turn being played.
  • Shop choice. Rules.emit("shopBuy", { seat = 1, key = "shield" }) picks an item from the sheet; without one the referee buys by heuristic when the prompt times out. The stock is four items — Star (at Rules.STAR_COST, the one that wins), Double Die, Shield, Lucky Charm — and key = "star" buys the Star.

Fields

FieldWhat it does
paceClock multiplier. 1 is real time; 4 plays four times as fast.
showdownSecondsCOIN CLASH length; 0 takes Rules.SHOWDOWN_SECONDS (60).
shopSecondsHow long a shop sheet waits for a choice; 0 takes 8 s for the human seat, 1.4 s for a CPU.
verboseLogs every beat to the console.

What it leaves in Rules.state

phase (title / roundIntro / turn / rolling / moving / resolving / roundEnd / showdown / ceremony), round, rounds, laps (laps per round, 4), lap (the lap being played), turnSeat, players (coins, stars, tile, items), die, shop (four items while a shop is open), lastResolve, showdownActive, showdownScores, lastShowdown, rankings, winner (name), winnerSeat, winners (names, more than one on a shared win), tie, message, seq.

Done when

A three-round match plays from title to ceremony with no input, ends with a named winner, and state.rankings (and the matchEnd payload) equals Rules.rankings(players) for those same players.