Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Created May 15, 2015 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjazdzewski1990/41569d4e2c0c5356fb5f to your computer and use it in GitHub Desktop.
Save pjazdzewski1990/41569d4e2c0c5356fb5f to your computer and use it in GitHub Desktop.
def handleCommand(command: GameCommand): Either[GameRulesViolation, Game] = command match {
case StartGame(players) => this match {
case ug: UninitializedGame => ug.start(players)
case _ => GameAlreadyStartedViolation
}
case RollDice(player) => this match {
case rg: RunningGame => rg.roll(player)
case _ => GameNotRunningViolation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment