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
 /*
  *  Allow the player to pick any two available resources from the bank for no cost.
  */
 public void loadYearOfPlenty(Player pl)
 {
     initiatingPlayer         = pl;
     lblTradeName.Text        = "Bank";
     lblPlayerTitle.Text      = pl.getName();
     lblPlayerTitle.BackColor = pl.getColor();
     //Allow the player to choose resources much like they can with the harbor trade
     for (int i = 0; i < 5; i++)
     {
         ResourceSelector otherSelector = new ResourceSelector((Board.ResourceType)i);
         otherResourceSelectors.Add(otherSelector);
         pnlOther.Controls.Add(otherSelector);
         otherSelector.Location = new Point(5, i * otherSelector.Height + 1);
         otherSelector.Click   += yearOfPlentyClickResourceSelector;
         otherSelector.hideControls();
     }
 }
Ejemplo n.º 3
0
        /*
         *  Allow the player to trade with the chosen harbor.
         */
        public void loadHarborTrade(Harbor hb, Player pl)
        {
            //Auto selects resources from other party (some trades allows the player to choose the resource)
            //Build the window based on the harbor.
            initiatingPlayer = pl;
            createResourceSelectors(false, false);
            minimumPlayerInput       = hb.getRequiredResourceCount();
            lblTradeName.Text        = "Harbor";
            lblPlayerTitle.Text      = pl.getName();
            lblPlayerTitle.BackColor = pl.getColor();
            foreach (ResourceSelector sel in playerResourceSelectors)
            {
                sel.Click += lockedTradePlayerClickPlayerResource;
            }

            if (hb.getTradeOutputResource() == Board.ResourceType.Desert)
            {
                //The player may choose any resource to trade for.
                foreach (ResourceSelector select in otherResourceSelectors)
                {
                    select.Click += playerClickOtherResource;
                }
            }
            else
            {
                //The player is only allowed to choose the one resource.
                canClearOther = false;
                foreach (ResourceSelector select in otherResourceSelectors)
                {
                    if (select.type == hb.getTradeOutputResource())
                    {
                        select.setSelected(true);
                    }
                    else
                    {
                        select.Hide();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /*
         *  Allow the player to trade any 4 of the same resource for any one other available resource from the bank.
         */
        public void loadBankTrade(Player pl)
        {
            //Bank automatically selects the number of resources on the other party
            initiatingPlayer = pl;

            //Auto selects resources from other party (some trades allows the player to choose the resource)
            //Build the window based on the harbor.
            initiatingPlayer = pl;
            createResourceSelectors(false, false);
            minimumPlayerInput       = 4;
            lblTradeName.Text        = "Bank";
            lblPlayerTitle.Text      = pl.getName();
            lblPlayerTitle.BackColor = pl.getColor();
            foreach (ResourceSelector sel in playerResourceSelectors)
            {
                sel.Click += lockedTradePlayerClickPlayerResource;
            }

            foreach (ResourceSelector select in otherResourceSelectors)
            {
                select.Click += playerClickOtherResource;
            }
        }
Ejemplo n.º 5
0
 /*
  *
  */
 public void loadMonopoly(Player pl)
 {
     pnlOther.Visible          = false;
     btnClearSelection.Visible = false;
     lblInstructions.Text     += "Please select the resource you wish to take from the other players.";
     lblInstructions.Visible   = true;
     lblTradeName.Text         = "";
     lblPlayerTitle.Text       = pl.getName();
     lblPlayerTitle.BackColor  = pl.getColor();
     btnAccept.Click          -= acceptClickToBank;
     btnAccept.Click          += acceptClickMonopoly;
     btnAccept.Enabled         = false;
     //Load all resource selectors.
     for (int i = 0; i < 5; i++)
     {
         ResourceSelector resSelect = new ResourceSelector((Board.ResourceType)i);
         resSelect.hideControls();
         pnlPlayer.Controls.Add(resSelect);
         resSelect.Location = new Point(5, i * resSelect.Height + 1);
         playerResourceSelectors.Add(resSelect);
         resSelect.Click += clickMonopoly;
     }
 }
Ejemplo n.º 6
0
        /*
         *  Allow the player to trade with another player.
         */
        public void loadPlayerTrade(Player currentPlayer, Player otherPlayer)
        {
            //Both players choose their resources.
            initiatingPlayer         = currentPlayer;
            lblPlayerTitle.Text      = currentPlayer.getName();
            lblPlayerTitle.BackColor = currentPlayer.getColor();
            this.otherPlayer         = otherPlayer;
            lblTradeName.Text        = otherPlayer.getName();
            lblTradeName.BackColor   = otherPlayer.getColor();
            otherPlayer.Current      = true;
            btnAccept.Click         -= acceptClickToBank;
            btnAccept.Click         += acceptClickPlayerToPlayer;
            createResourceSelectors(false, false);
            foreach (ResourceSelector sel in playerResourceSelectors)
            {
                sel.Click += ptpClickResourceSelectorPlayer;
            }

            foreach (ResourceSelector sel in otherResourceSelectors)
            {
                sel.Click += ptpClickResourceSelectorOther;
            }
        }
 public static string PlayerEndedTurn(Player currentPlayer)
 {
     return(currentPlayer.getName() + " has ended their turn.");
 }
 public static string PlayerGoNoResourceFromPlayer(Player toPlayer, Player fromPlayer)
 {
     return(toPlayer.getName() + " got no resource cards from " + fromPlayer.getName() + " because they have none to give.");
 }
 public static string PlayerGotResourceFromPlayer(Player toPlayer, Player fromPlayer, Board.ResourceType res)
 {
     return(toPlayer.getName() + " got " + Board.RESOURCE_NAMES[(int)res] + " from " + fromPlayer.getName() + ".");
 }
Ejemplo n.º 10
0
 public static String LocationOwnedBy(Player owner)
 {
     return("This location is already owned by " + owner.getName());
 }
Ejemplo n.º 11
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.º 12
0
 public static string PlayerBuiltACity(Player player)
 {
     return(player.getName() + " built a city.");
 }
Ejemplo n.º 13
0
 public static string PlayerWinsDiceRoll(Player player)
 {
     return("Congrats player " + player.getName() + " you won the roll and are the first player!");
 }
Ejemplo n.º 14
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.º 15
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.º 16
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.º 17
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.º 18
0
 public static string PlayerRolledANumber(Player player, int number)
 {
     return(player.getName() + " rolled " + (number == 8 || number == 11 ? "an " : "a ") + number + ".");
 }
Ejemplo n.º 19
0
 public static string PlayerPurchasedADevCard(Player player)
 {
     return(player.getName() + " purchased a development card.");
 }
Ejemplo n.º 20
0
 public static string PlayerDiceRollPrompt(Player player)
 {
     return(player.getName() + " please roll the dice.");
 }
Ejemplo n.º 21
0
 public static string RobberHasMoved(Player player)
 {
     return(player.getName() + " has moved the robber.");
 }
Ejemplo n.º 22
0
 public static string PlayerPlacedASettlement(Player player)
 {
     return(player.getName() + " placed a settlement.");
 }
Ejemplo n.º 23
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);
 }
Ejemplo n.º 24
0
 public static string PlayerPlacedARoad(Player player)
 {
     return(player.getName() + " placed a road.");
 }
Ejemplo n.º 25
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.º 26
0
 public static string PlayerUsedRoadBuilding(Player player)
 {
     return(player.getName() + " used a Road Building card.");
 }
Ejemplo n.º 27
0
        public void TestConstructor()
        {
            var player0 = new Player();
            Assert.NotNull(player0);

            String playerName = "player1";
            Color playerColor = Color.Beige;
            var world = new World();
            var player1 = new Player(playerName, playerColor, world);
            Assert.IsTrue(player1.getColor() == playerColor);
            Assert.IsTrue(player1.getName() == playerName);
        }
Ejemplo n.º 28
0
 public static string PlayerMoveThief(Player player)
 {
     return(player.getName() + " please select a terrain tile to move the thief into.");
 }
Ejemplo n.º 29
0
        public void checkForWinner()
        {
            //Yay!

            //Update the largest army and longest road stuff
            Player lapl = null;
            Player llpl = null;

            foreach (Player pl in playerOrder)
            {
                int arm = pl.getArmySize();
                if (arm > largestArmy)
                {
                    lapl        = pl;
                    largestArmy = arm;
                }

                arm = pl.getLongestRoadCount();
                if (arm > longestRoad)
                {
                    llpl        = pl;
                    longestRoad = arm;
                }
                pl.setLongestRoad(false);
                pl.setLargestArmy(false);
            }
            if (largestArmy >= 3)
            {
                if (lapl != null)
                {
                    foreach (Player pl in playerOrder)
                    {
                        pl.setLargestArmy(false);
                    }
                    lapl.setLargestArmy(true);
                }
            }
            if (longestRoad >= 5)
            {
                if (llpl != null)
                {
                    foreach (Player pl in playerOrder)
                    {
                        pl.setLongestRoad(false);
                    }
                    llpl.setLongestRoad(true);
                }
            }

            bool   winner        = false;
            Player winningPlayer = null;

            foreach (Player pl in playerOrder)
            {
                int vps = Player.calculateVictoryPoints(true, pl);
                if (vps >= 10)
                {
                    winningPlayer = pl;
                    winner        = true;
                }
                else
                {
                    pl.updateScore();
                }
            }
            if (winner)
            {
                currentGameState = GameState.End;
                currentGameEvent.endExecution();
                addEventText(winningPlayer.getName() + " has won!");
            }
        }