//public void PlayMoves(MoveSeries moves) //{ // if (_roundType == RoundType.VsComputer) // { // // Play computer moves first... // var computerMoves = new ComputerMoveGenerator().GetMoves(); // ApplyChange(new Player1MovesPlayed(_id, computerMoves, computerMoves.PlayerId)); // } // if (_player1Moves == null) // { // ApplyChange(new Player1MovesPlayed(_id, moves, moves.PlayerId)); // } // else if (_player2Moves == null) // { // ApplyChange(new Player2MovesPlayed(_id, moves, moves.PlayerId)); // HandleWinners(); // } // else // throw new InvalidOperationException("Cannot play more than 2 moves"); //} public void PlayMoves(MoveSeries moves, IWinnerCalculator winnerCalculator) { if (_roundType == RoundType.VsComputer) { if (_player1Moves == null) { ApplyChange(new Player1MovesPlayed(_id, moves, moves.PlayerId)); } //Play computer moves first... var computerMoves = new ComputerMoveGenerator().GetMoves(); ApplyChange(new Player2MovesPlayed(_id, computerMoves, computerMoves.PlayerId)); HandleWinners(winnerCalculator); }else { if (_player1Moves == null) { ApplyChange(new Player1MovesPlayed(_id, moves, moves.PlayerId)); }else if (_player2Moves == null) { ApplyChange(new Player2MovesPlayed(_id, moves, moves.PlayerId)); HandleWinners(winnerCalculator); } } }
private void Apply(Player2MovesPlayed e) { _player2Moves = e.Moves; }