Esempio n. 1
0
        public override void makePlay(int iPlayerIndex)
        {
            Console.Clear();
            //make variable for player
            Player player = Board.access().getPlayer(iPlayerIndex);

            //Change the colour for the player
            Console.ForegroundColor = this.colors[iPlayerIndex];

            //if inactive skip turn
            if (player.isNotActive())
            {
                Console.WriteLine("\n{0} is inactive.\n", player.getName());
                //check players to continue
                //check that there are still two players to continue
                int activePlayerCount = 0;
                foreach (Player p in Board.access().getPlayers())
                {
                    //if player is active
                    if (!p.isNotActive())
                    {
                        //increment activePlayerCount
                        activePlayerCount++;
                    }
                }

                //if less than two active players display winner
                if (activePlayerCount < 2)
                {
                    this.printWinner();
                }

                return;
            }



            //prompt player to make move
            Console.WriteLine("{0}Your turn. Press Enter to make move", playerPrompt(iPlayerIndex));
            Console.ReadLine();
            //move player
            player.move();

            //Display making move
            Console.WriteLine("*****Move for {0}:*****", player.getName());
            //Display rolling
            Console.WriteLine("{0}{1}\n", playerPrompt(iPlayerIndex), player.diceRollingToString());

            Property propertyLandedOn = Board.access().getProperty(player.getLocation());

            //landon property and output to console
            Console.WriteLine(propertyLandedOn.landOn(ref player));
            //Display player details
            Console.WriteLine("\n{0}{1}", playerPrompt(iPlayerIndex), player.BriefDetailsToString());
            //display player choice menu
            displayPlayerChoiceMenu(player);
        }
Esempio n. 2
0
 public void purchaseProperty(Player player)
 {
     //if property available give option to purchase else so not available
     if (Board.access().getProperty(player.getLocation()).availableForPurchase())
     {
         TradeableProperty propertyLocatedOn = (TradeableProperty)Board.access().getProperty(player.getLocation());
         bool respYN = getInputYN(player, string.Format("'{0}' is available to purchase for ${1}. Are you sure you want to purchase it?", propertyLocatedOn.getName(), propertyLocatedOn.getPrice()));
         if (respYN)
         {
             propertyLocatedOn.purchase(ref player);//purchase property
             Console.WriteLine("{0}You have successfully purchased {1}.", playerPrompt(player), propertyLocatedOn.getName());
         }
     }
     else
     {
         Console.WriteLine("{0}{1} is not available for purchase.", playerPrompt(player), Board.access().getProperty(player.getLocation()).getName());
     }
 }
Esempio n. 3
0
 public void purchaseProperty(Player player)
 {
     //if property available give option to purchase else so not available
     if (Board.access().getProperty(player.getLocation()).availableForPurchase())
     {
         TradeableProperty propertyLocatedOn = (TradeableProperty)Board.access().getProperty(player.getLocation());
         bool respYN = getInputYN(player, string.Format("'{0}' is available to purchase for ${1}. Are you sure you want to purchase it?", propertyLocatedOn.getName(), propertyLocatedOn.getPrice()));
         if (respYN)
         {
             propertyLocatedOn.purchase(ref player);//purchase property
             Console.WriteLine("{0}You have successfully purchased {1}.", playerPrompt(player), propertyLocatedOn.getName());
         }
     }
     else
     {
         Console.WriteLine("{0}{1} is not available for purchase.", playerPrompt(player), Board.access().getProperty(player.getLocation()).getName());
     }
 }
        public void test_PlayerGettersAndSetters()
        {
            Banker theTestBanker = new Banker();
             Player theTestPlayer = new Player();

            //hasRolledDoubles bool
            theTestPlayer.get_hasRolledDoubles();
            theTestPlayer.is_hasRolledDoubles();
            theTestPlayer.hasRolledDoubles = true;
            theTestPlayer.not_hasRolledDoubles();

            //paidFine bool
            theTestPlayer.getPaidFine();
            theTestPlayer.isPaidFine();
            theTestPlayer.notPaidFine();

            //landedInJailByThreeStraightDoubles bool
            theTestPlayer.get_LandedInJailByThreeStraightDoubles();
            theTestPlayer.not_LandedInJailByThreeStraightDoubles();
            theTestPlayer.is_LandedInJailByThreeStraightDoubles();

            //inJail bool
            theTestPlayer.getJailStats();
            theTestPlayer.setIsInJail();
            theTestPlayer.setNotInJail();

            //lastMove int
            theTestPlayer.getLastMove();

            theTestPlayer.getLocation();

            theTestPlayer.getName();

            theTestPlayer.getPropertiesOwned();

            theTestPlayer.getBalance();

            theTestPlayer.getBalance();

            theTestPlayer.hasRolledDoublesInJail();

            theTestPlayer.isNotActive();

            theTestPlayer.get_firstTurnInJail();

            theTestPlayer.not_firstTurnInJail();
        }