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 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 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 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);
        }
        public void TestBuildVerticalRoadThrowsOnBadXValues()
        {
            World w = new World(3, 0, null);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.currentPlayer.getHand().incrementAllResources(1);
            w.currentPlayer.getHand().incrementAllResources(1);

            w.getMap().getIslandMap().buildVerticalRoad(new Point(2, 3), w.currentPlayer);
        }
Exemplo n.º 6
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());
        }
Exemplo n.º 7
0
 public void TestGetHexAtIndex()
 {
     var target = new World();
     Assert.AreEqual(target.getMap().getHexMap().map[2, 2], target.getHexAtIndex(2, 2));
 }
 public void TestThatPlayerCannotBuildSettlementIfThereIsNoRoadLeadingThere()
 {
     World world = new World(3, 0, null);
     var player = new Player("annie", Color.Pink, world);
     Assert.False(world.getMap().getIslandMap().getIntAtIndex(3, 3).canBuildAtIntersection(player, 5));
 }