public void DoEndTurnTest() { game.MovePieceCount = 1; // simulation d'un MovePiece afin d'executer la commande endTurn endTurn.Do(game); int nextPlayer = game.CurrentPlayer; if (previousPlayer == 1) { Assert.IsTrue(nextPlayer == 0); } else { Assert.IsTrue(nextPlayer == 1); } }
public void Update(Command cmd) { if (cmd.CanDo(this)) { cmd.Do(this); if (cmd is MoveBall) { MoveBallCount++; } if (cmd is MovePiece) { MovePieceCount++; } CommandHistory.Push(new CommandMemento(cmd)); UndoHistory.Clear(); //Console.Write(Board.ToString()); if (IsWin()) { VictoriousPlayer = Players[CurrentPlayer]; } if (IsEndTurn()) { Command endTurn = new EndTurn(); CommandHistory.Push(new CommandMemento(endTurn)); endTurn.Do(this); } } else { throw new InvalidOperationException("Impossible d'effectuer l'action " + cmd.GetType() + " : " + cmd.ToString()); } }