Skip to content

LegalMove

fun interface LegalMove<out GameState : Game>

A player action.

The different Game state transition methods (GameNotStarted.start, GameNewTurn.play, etc.) only verify that a move is legal but do not perform it. This allows UIs to eagerly verify if a move is legal.

To perform the move, call perform, which will return the new game state after the move has taken place.

Functions

invoke

open operator fun invoke(): GameState

Same as perform, allows using the () operator on this type.

perform

abstract fun perform(): GameState

Performs the move encoded in this instance.

Returns the new game state after the move has taken place.