public void TestBoardWithTwoBlocksGetUserArmies()
        {
            var board      = new BlockBoardStorage(1, 2, null);
            var items      = new BoardStorageItem[3, 3];
            var bonusItems = new BoardStorageItem[3, 3];
            var playerType = PlayerType.FIRST;

            var item1 = new ArmyStorageItem(new UserArmy(playerType, null), null);
            var item2 = new ArmyStorageItem(new UserArmy(playerType, null), null);
            var item3 = new ArmyStorageItem(new UserArmy(playerType, null), null);
            var item4 = new ArmyStorageItem(new UserArmy(playerType, null), null);

            items[1, 1] = item1;
            items[2, 2] = item2;

            board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems);

            items[1, 1] = item3;
            items[2, 2] = item4;

            board.FillBlockForTesting(new IntVector2(1, 2), items, bonusItems);

            var armies = board.FindPlayerArmies(playerType);

            Assert.True(armies.Count == 4);
        }
        public void TestGetUserArmiesWithoutArmies()
        {
            var board      = new BlockBoardStorage(1, 1, null);
            var items      = new BoardStorageItem[3, 3];
            var bonusItems = new BoardStorageItem[3, 3];

            var item1 = new ArmyStorageItem(new UserArmy(PlayerType.FIRST, null), null);
            var item2 = new ArmyStorageItem(new UserArmy(PlayerType.FIRST, null), null);

            items[1, 1] = item1;
            items[2, 2] = item2;

            board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems);

            var foundItems = board.FindPlayerArmies(PlayerType.SECOND);

            Assert.True(foundItems.Count == 0);
        }
Esempio n. 3
0
        public void TestInvertBoard()
        {
            int width  = 3;
            int height = 2;

            var board      = new SingleBoardStorage(width, height, null);
            var bonusTable = new BoardStorageItem[width + 1, height + 1];
            var boardTable = new BoardStorageItem[width + 1, height + 1];
            var pass       = new Pass(null, null, null, null, null);
            var item       = new ArmyStorageItem(null, null);

            bonusTable[2, 1] = pass;
            boardTable[3, 2] = item;

            board.Fill(boardTable, bonusTable);
            board.InvertBoard();

            Assert.AreSame(board.GetItem(3, 2), null);
            Assert.AreSame(board.GetBonusItem(2, 1), null);
            Assert.AreSame(board.GetItem(2, 2), item);
            Assert.AreSame(board.GetBonusItem(1, 1), pass);
        }
Esempio n. 4
0
        public void TestFindPlayerArmies()
        {
            var firstPlayerType  = PlayerType.FIRST;
            var secondPlayerType = PlayerType.SECOND;

            int size       = 3;
            var board      = new SingleBoardStorage(size, size, null);
            var bonusTable = new BoardStorageItem[size + 1, size + 1];
            var boardTable = new BoardStorageItem[size + 1, size + 1];

            boardTable[2, 2] = new ArmyStorageItem(new UserArmy(firstPlayerType, null), null);
            boardTable[1, 2] = new ArmyStorageItem(new UserArmy(firstPlayerType, null), null);

            board.Fill(boardTable, bonusTable);

            Assert.True(board.ContainsPlayerArmies(firstPlayerType));
            Assert.False(board.ContainsPlayerArmies(secondPlayerType));

            var armies = board.FindPlayerArmies(firstPlayerType);

            Assert.True(armies.Contains(board.GetCellByPosition(new IntVector2(1, 2))));
            Assert.True(armies.Contains(board.GetCellByPosition(new IntVector2(2, 2))));
            Assert.True(armies.Count == 2);
        }