public void TestBuildVerticalRoad()
        {
            World w = new World(3, 0, null);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.tryToBuildAtIntersection(new Point(1, 5));
            bool flag = w.getMap().getIslandMap().buildVerticalRoad(new Point(3, 2), w.currentPlayer);
            Assert.True(flag);

            flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(4, 4), w.currentPlayer);
            Assert.True(flag);

            flag = w.getMap().getIslandMap().buildVerticalRoad(new Point(5, 2), w.currentPlayer);
            Assert.True(flag);

            flag = w.getMap().getIslandMap().buildVerticalRoad(new Point(9, 3), w.currentPlayer);
            Assert.False(flag);

            // for testing private method roadHasConnectingRoad
            flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(4, 5), w.currentPlayer);
            Assert.True(flag);

            flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(4, 3), w.currentPlayer);
            Assert.True(flag);
        }
        public void TestBuildHorizontalRoad()
        {
            World w = new World(3, 0, null);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.tryToBuildAtIntersection(new Point(0, 3));
            bool flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(0, 0), w.currentPlayer);
            Assert.True(flag);

            w.currentPlayer.getHand().incrementAllResources(1);
            w.tryToBuildAtIntersection(new Point(1, 4));
            flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(2, 2), w.currentPlayer);
            Assert.True(flag);

            w.currentPlayer.getHand().incrementAllResources(1);
            w.tryToBuildAtIntersection(new Point(3, 5));
            flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(6, 4), w.currentPlayer);

            flag = w.getMap().getIslandMap().buildHorizontalRoad(new Point(8, 6), w.currentPlayer);
            Assert.False(flag);
        }
 public void TestThatIntersectionCanDetemineWhenPlayerHasExistingConnection()
 {
     var world = new World(3, 0, null);
     Player player = new Player("sam", Color.Turquoise, world);
     player.getHand().incrementAllResources(3);
     world.addPlayer(player);
     world.setCurrentPlayer(player.getName());
     Assert.AreNotEqual(Color.White, world.tryToBuildAtIntersection(new Point(2, 4)));
     Assert.AreNotEqual(Color.White, world.roadButtonClicked(new Point(4, 4)));
     Assert.True(world.getMap().getIslandMap().getIntAtIndex(new Point(2, 5)).playerHasExistingConnection(Color.Turquoise));
 }
        public void TestRoadHasPlayerBuildingAtSecondIntersection()
        {
            // IslandMap newMap = new IslandMap();
            World w = new World(3, 0, null);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.tryToBuildAtIntersection(new Point(0, 3));

            bool flag = w.getMap().getIslandMap().roadHasPlayerBuilding(new Point(0, 2), new Point(0, 3), w.currentPlayer);
            Assert.True(flag);
        }
예제 #5
0
        public void TestTryToBuildCityAtIntersectionWithoutEnoughResources()
        {
            World w = new World(3, 0, null);
            Player player1 = new Player("Meeeeee!", Color.HotPink, w);
            w.addPlayer(player1);
            w.setCurrentPlayer(player1.getName());

            w.currentPlayer.getHand().incrementAllResources(1);

            w.tryToBuildAtIntersection(new Point(3, 4));
            Color c = w.tryToBuildAtIntersection(new Point(3, 4));
            Assert.AreEqual(Color.White, c);
        }
예제 #6
0
        public void TestThatVerticalRoadIsBuiltIfPlayerHasSettlement()
        {
            World world = new World(3, 0, null);
            Player player1 = new Player("Meeeeee!", Color.HotPink, world);
            world.addPlayer(player1);
            world.setCurrentPlayer(player1.getName());

            // Give player 5 resources of each except ore
            player1.getHand().modifyBrick(5);
            player1.getHand().modifyGrain(5);
            player1.getHand().modifyLumber(5);
            player1.getHand().modifyWool(5);
            world.tryToBuildAtIntersection(new Point(0, 2));
            Assert.AreEqual(Color.HotPink, world.roadButtonClicked(new Point(1, 0)));
        }
예제 #7
0
        public void TestThatSettlementGetsBuild()
        {
            World world = new World(3, 0, null);
            Player player1 = new Player("Meeeeee!", Color.HotPink, world);
            world.addPlayer(player1);
            world.setCurrentPlayer(player1.getName());

            // Give player the resources needed for a settlement
            player1.getHand().modifyBrick(1);
            player1.getHand().modifyGrain(1);
            player1.getHand().modifyLumber(1);
            player1.getHand().modifyWool(1);
            Assert.AreEqual(Color.HotPink, world.tryToBuildAtIntersection(new Point(3, 3)));
            Assert.AreEqual(Global_Variables.GAME_PIECE.SETTLEMENT,
                world.getMap().getIslandMap().getIntAtIndex(3, 3).getPieceType());

            // Give player the resources needed for city
            player1.getHand().modifyOre(5);
            player1.getHand().modifyGrain(5);
            Assert.AreEqual(Color.Black, world.tryToBuildAtIntersection(new Point(3, 3)));
            Assert.AreEqual(Global_Variables.GAME_PIECE.CITY,
                world.getMap().getIslandMap().getIntAtIndex(3, 3).getPieceType());
        }
예제 #8
0
        public void TestThatBuildingRoadReturnsWhiteIfIndexIsOutOfRange()
        {
            World world = new World(3, 0, null);
            Player player1 = new Player("Meeeeee!", Color.HotPink, world);
            world.addPlayer(player1);
            world.setCurrentPlayer(player1.getName());

            // Give player 5 resources of each except ore
            player1.getHand().modifyBrick(5);
            player1.getHand().modifyGrain(5);
            player1.getHand().modifyLumber(5);
            player1.getHand().modifyWool(5);
            world.tryToBuildAtIntersection(new Point(0, 2));
            Assert.AreEqual(Color.White, world.roadButtonClicked(new Point(52, 1)));
        }
예제 #9
0
        public void TestRoadButtonClicked()
        {
            World w = new World(3, 0, null);
            Player player1 = new Player("Meeeeee!", Color.HotPink, w);
            w.addPlayer(player1);
            w.setCurrentPlayer(player1.getName());
            Color C = w.roadButtonClicked(new Point(2, 2));
            //insufficiant resources
            Assert.AreEqual(Color.White, C);

            w.currentPlayer.getHand().incrementAllResources(5);

            //point without adjoining settlement
            C = w.roadButtonClicked(new Point(3, 2));
            Assert.AreEqual(Color.White, C);
            //even point with resources
            w.tryToBuildAtIntersection(new Point(0, 3));
            C = w.roadButtonClicked(new Point(0, 0));
            Assert.AreEqual(Color.HotPink, C);
            //odd point with resources
            w.tryToBuildAtIntersection(new Point(1, 5));
            C = w.roadButtonClicked(new Point(3, 2));
            Assert.AreEqual(Color.HotPink, C);
            //point that is not in the grid
            C = w.roadButtonClicked(new Point(50, 2));
            Assert.AreEqual(Color.White, C);
            //point that has not been initialized
            w.catanMap = null;
            C = w.roadButtonClicked(new Point(3, 2));
            Assert.AreEqual(Color.Black, C);
        }