Single active player
Use a single-player stage for ordinary turns:.activePlayer() runs whenever the engine enters the stage. .transition() runs after an accepted command.
For self-references such as playerTurn, add an explicit stage type or create stages through functions that resolve references lazily.
Automatic stage
Use an automatic stage for rule work that needs no player input:.run() immediately, then follows .transition(). It continues through automatic stages until it reaches a stage waiting for players or an automatic stage with no transition.
Multiple active players
Use a multi-active-player stage when several players may submit independently, such as choosing a card at the same time.execute(command) inside .onSubmit() when you want the submitted command’s .execute() handler to run.
End a game
A terminal automatic stage can omit.transition():
Keep transitions short. Put state changes in command execution or
.run() so it is clear where rules mutate the game.Assemble the definition
Connect state, events, setup, and the initial stage.