Created
July 11, 2022 07:58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<IEvent> Handle(MakeMoveCommand cmd) | |
{ | |
if (EState.Created == State) | |
{ | |
return new List<IEvent> | |
{ | |
new MoveDecidedEvent(cmd.GameId, cmd.PlayerEmail, cmd.Move) | |
}; | |
} | |
else if (EState.Waiting == State) | |
{ | |
if (Player == cmd.PlayerEmail) throw new ArgumentException($"Player already in game: {cmd.PlayerEmail}"); | |
return new List<IEvent> | |
{ | |
new MoveDecidedEvent(cmd.GameId, cmd.PlayerEmail, cmd.Move), | |
MakeEndGameEvent(cmd.GameId, cmd.PlayerEmail, cmd.Move) | |
}; | |
} | |
else | |
{ | |
throw new InvalidOperationException($"Invalid game state: {State}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment