public void SetUp() { player1 = new Player("Player 1"); player2 = new Player("Player 2"); game = Game.CreateNewGame(10, 10, player1, player2); log = new JsonMessageLog(); }
private void DispatchMessages(JsonMessageLog log) { if (log.Messages.Count > 0) { var array = new JsonArray(log.Messages); clients.Broadcast(array.ToString()); } }
public void ProcessCommand(GameCommand command) { lock (commandLock) { var log = new JsonMessageLog(); command.Execute(game, log); DispatchMessages(log); } }
public void PlayerStartingPositionsAreLogged() { var player1 = new Player("Player 1"); var player2 = new Player("Player 2"); var game = Game.CreateNewGame(10, 10, player1, player2); var log = new JsonMessageLog(); var command = new StartGameCommand(); command.Execute(game, log); log.AssertMessageTypes(GameMessageType.NewGame, GameMessageType.PlayerAdded, GameMessageType.PlayerAdded); }
public void TwoPlayersStartInOppositeCorners() { var player1 = new Player("Player 1"); var player2 = new Player("Player 2"); var game = Game.CreateNewGame(10, 10, player1, player2); var log = new JsonMessageLog(); var command = new StartGameCommand(); command.Execute(game, log); var pos1 = player1.Position; var pos2 = player2.Position; Assert.AreEqual(0, pos1.X); Assert.AreEqual(0, pos1.Y); Assert.AreEqual(9, pos2.X); Assert.AreEqual(9, pos2.Y); }