예제 #1
0
        public MoveResult Move(PlayerToken playerToken)
        {
            var diceResult = _dice.Roll();

            if (!ValidateMove(playerToken, diceResult))
            {
                return new MoveResult {
                           NewSquare = playerToken.GetCurrentSquare(), Status = MoveStatus.Rejected
                }
            }
            ;

            playerToken.Move(diceResult);

            if (IsPlayerWon(playerToken))
            {
                return new MoveResult {
                           NewSquare = playerToken.GetCurrentSquare(), Status = MoveStatus.GameWon
                }
            }
            ;

            return(new MoveResult {
                NewSquare = playerToken.GetCurrentSquare(), Status = MoveStatus.Moved
            });
        }
예제 #2
0
 private bool IsPlayerWon(PlayerToken playerToken)
 {
     return(playerToken.GetCurrentSquare() == _gameSettings.WinnerSquare);
 }
예제 #3
0
 private bool ValidateMove(PlayerToken playerToken, int diceResult)
 {
     return(playerToken.GetCurrentSquare() + diceResult <= _gameSettings.WinnerSquare);
 }