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));
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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)));
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
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)));
        }
Ejemplo n.º 6
0
 public void testRollDice()
 {
     World w = new World(3, 0, null);
     Player player1 = new Player("Meeeeee!", Color.HotPink, w);
     w.addPlayer(player1);
     w.setCurrentPlayer(player1.getName());
     //test without completeing early rounds
     w.rollDice();
     Assert.IsFalse(w.currentPlayer.hasRolled);
     //test extra roll without completeing early rounds
     w.rollDice();
     Assert.IsFalse(w.currentPlayer.hasRolled);
     w.numOfCompletedRounds = 5;
     //test first roll after early rounds
     w.rollDice();
     Assert.IsTrue(w.currentPlayer.hasRolled);
     //test extra roll after early rounds
     w.rollDice();
     Assert.IsTrue(w.currentPlayer.hasRolled);
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 public void testGetRollNumber()
 {
     World w = new World(3, 0, null);
     Player player1 = new Player("Meeeeee!", Color.HotPink, w);
     w.addPlayer(player1);
     w.setCurrentPlayer(player1.getName());
     //test getting roll number without rolling
     Assert.AreEqual(0, w.getRollNumber());
     w.numOfCompletedRounds = 5;
     //test getting roll number after rolling
     w.rollDice();
     Assert.IsTrue(w.getRollNumber() < 13 && w.getRollNumber() > 1);
 }