상속: IMessageLog
 public void SetUp()
 {
     player1 = new Player("Player 1");
     player2 = new Player("Player 2");
     game = Game.CreateNewGame(10, 10, player1, player2);
     log = new JsonMessageLog();
 }
예제 #2
0
 private void DispatchMessages(JsonMessageLog log)
 {
     if (log.Messages.Count > 0)
     {
         var array = new JsonArray(log.Messages);
         clients.Broadcast(array.ToString());
     }
 }
예제 #3
0
 public void ProcessCommand(GameCommand command)
 {
     lock (commandLock)
     {
         var log = new JsonMessageLog();
         command.Execute(game, log);
         DispatchMessages(log);
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 private void DispatchMessages(JsonMessageLog log)
 {
     if (log.Messages.Count > 0)
     {
         var array = new JsonArray(log.Messages);
         clients.Broadcast(array.ToString());
     }
 }
예제 #7
0
 public void ProcessCommand(GameCommand command)
 {
     lock (commandLock)
     {
         var log = new JsonMessageLog();
         command.Execute(game, log);
         DispatchMessages(log);
     }
 }