Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Created May 15, 2015 11:36
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/3b5bb89ba83d1575b04d to your computer and use it in GitHub Desktop.
Save pjazdzewski1990/3b5bb89ba83d1575b04d to your computer and use it in GitHub Desktop.
sealed trait Game {
def handleCommand(command: GameCommand): Either[GameRulesViolation, Game]
def applyEvent: PartialFunction[GameEvent, Game]
}
case class UninitializedGame(...) extends Game {
def start(players: Seq[PlayerId]): Either[GameRulesViolation, Game]
}
case class RunningGame(...) extends Game {
def roll(player: PlayerId): Either[GameRulesViolation, Game]
def tickCountdown(): Game
}
case class FinishedGame(...) extends Game {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment