public void SetUp()
        {
            testgame = new Game.Game(new GameStartOptions {
                Height = 2, Width = 2, StartingArmiesPerPlayer = 5
            });
            testgame.StartJoining();
            player1Token = Guid.NewGuid().ToString();
            player2Token = Guid.NewGuid().ToString();
            testgame.AddPlayer(new ApiPlayer("player1", player1Token, null));
            testgame.AddPlayer(new ApiPlayer("player2", player2Token, null));

            testgame.StartGame();

            //place 5 armies
            testgame.TryPlaceArmy(player1Token, territory1.Location);
            testgame.TryPlaceArmy(player1Token, territory1.Location);
            testgame.TryPlaceArmy(player1Token, territory1.Location);
            testgame.TryPlaceArmy(player1Token, territory1.Location);
            testgame.TryPlaceArmy(player1Token, territory1.Location);

            //player2 places 5 armies
            testgame.TryPlaceArmy(player2Token, territory2.Location);
            testgame.TryPlaceArmy(player2Token, territory2.Location);
            testgame.TryPlaceArmy(player2Token, territory2.Location);
            testgame.TryPlaceArmy(player2Token, territory2.Location);
            testgame.TryPlaceArmy(player2Token, territory2.Location);
        }
Ejemplo n.º 2
0
        public void Setup()
        {
            int width  = 2;
            int height = 2;


            IPlayer player  = new ApiPlayer("Rusty", "bazookaJoe", null);
            IPlayer player2 = new ApiPlayer("Emmanuel", "Macaco", null);

            game = new Game.Game(new GameStartOptions {
                Height = height, Width = width, StartingArmiesPerPlayer = 3
            });
            game.AddPlayer(new ApiPlayer("Rusty", "bazookaJoe", null));
            game.AddPlayer(new ApiPlayer("Emmanuel", "Macaco", null));
            Location attacker  = new Location(1, 1);
            Location attacker2 = new Location(0, 1);
            Location defender  = new Location(0, 0);
            Location defender2 = new Location(1, 0);

            game.StartGame();

            game.TryPlaceArmy(player.Token, attacker);
            game.TryPlaceArmy(player.Token, attacker);
            game.TryPlaceArmy(player.Token, attacker2);

            game.TryPlaceArmy(player2.Token, defender);
            game.TryPlaceArmy(player2.Token, defender);
            game.TryPlaceArmy(player2.Token, defender2);
        }
Ejemplo n.º 3
0
        public void CanChangeStateFromJoiningToArmyDeployment()
        {
            Assert.AreEqual(GameState.Joining, game.GameState);

            game.StartGame();

            var actual = game.GameState;

            Assert.AreEqual(GameState.Deploying, actual);
        }
        public void SetUp()
        {
            game = new Game.Game(new GameStartOptions {
                Height = 2, Width = 2, StartingArmiesPerPlayer = 5
            });
            game.StartJoining();

            player1Token = Guid.NewGuid().ToString();
            player2Token = Guid.NewGuid().ToString();

            game.AddPlayer(new ApiPlayer("player1", player1Token, null));
            game.AddPlayer(new ApiPlayer("player2", player2Token, null));
            game.StartGame();
        }
        public void GetGameStatusHasPlayersWithArmyAndTerritoryCount()
        {
            var player1 = new ApiPlayer("player1", "token", null);

            game.AddPlayer(player1);

            game.StartGame();

            game.TryPlaceArmy(player1.Token, new Location(0, 0));

            var gameStatus = game.GetGameStatus();

            Assert.That(gameStatus.Board.Count() == 4);
            Assert.That(gameStatus.Board.Single(t => t.Location == new Location(0, 0)).Armies == 1);
        }
        public async Task <IActionResult> StartGame(StartGameRequest startGameRequest)
        {
            if (game.GameState != GameState.Joining)
            {
                return(BadRequest("Game not in Joining state"));
            }
            if (config["secretCode"] != startGameRequest.SecretCode)
            {
                return(BadRequest("Secret code doesn't match, unable to start game."));
            }
            game.StartGame();
            var gameRunner = new GameRunner(game, logger);
            await gameRunner.StartGameAsync();

            return(Ok());
        }
Ejemplo n.º 7
0
 public void StartNewGame()
 {
     Game.Game game = new Game.Game();
     Games.Add(game);
     // This is somewhat complicated code to move the dealer in each game. Probably refactor later to use the dealer property.
     game.StartGame(Players.Skip(GameIndex).Concat(Players.Take(GameIndex)).ToList(), prompt);
     ScrSheet.AddGameScore(game.Picker, game.Partner, game.GetPickerTrickCount(), game.IsCracked, game.GetPickerScore());
     while (true)
     {
         var answer = prompt(PromptType.GameOver, new Dictionary <PromptData, object>
         {
             { PromptData.Game, game }
         });
         if (answer != "")
         {
             break;
         }
     }
 }
        public async Task AddPlayerAfterGameStarts()
        {
            var game = new Game.Game(new GameStartOptions {
                Height = 2, Width = 2
            });

            game.StartJoining();

            var playerToken = Guid.NewGuid().ToString();

            game.AddPlayer(new ApiPlayer("player 1", playerToken, null));
            Guid.TryParse(playerToken, out var _).Should().BeTrue();
            game.StartGame();

            var gameController = new GameController(game, null, null, null, logger);

            var response = await gameController.Join(new JoinRequest { Name = "Player2", CallbackBaseAddress = "" });

            Assert.IsInstanceOf <BadRequestObjectResult>(response);
        }
Ejemplo n.º 9
0
        public void SetUp()
        {
            var httpClientMock = new Mock <HttpClient>();
            //httpClientMock.Setup()

            var loggerMock = new Mock <ILogger <GameRunner> >();

            game = new Game.Game(new GameStartOptions {
                Height = 2, Width = 2, StartingArmiesPerPlayer = 1
            });
            game.StartJoining();

            player1Token = Guid.NewGuid().ToString();
            player2Token = Guid.NewGuid().ToString();

            game.AddPlayer(new ApiPlayer("player1", player1Token, null));
            game.AddPlayer(new ApiPlayer("player2", player2Token, null));

            game.StartGame();
            gameRunner = new GameRunner(game, loggerMock.Object);
        }