Exemplo n.º 1
0
        //Method for FREE PROPERTY SPACE - player has to make decision whether he want to buy it or not
        private void FreeSpace(Player[] players, IList <Space> listOfSpaces, int currentPlayer, Player player, PurchasableSpace currentPropertySpace)
        {
            this.DrawEngine.DrawText(40, 30, "Player to decide - buy(1) OR pass(2) : ");
            bool isInvalidInput = true;
            int  decision       = 0;

            do
            {
                try
                {
                    decision = int.Parse(Console.ReadLine());
                    if (decision < 1 || decision > 2)
                    {
                        throw new InvalidPlayerChoiceException();
                    }
                }
                catch (InvalidPlayerChoiceException ex)
                {
                    this.DrawEngine.DrawText(40, 32, ex.Message);
                    continue;
                }
                isInvalidInput = false;
            } while (isInvalidInput);
            this.DrawEngine.DrawText(40, 32, new string(' ', 30));


            if (decision == 1)
            {
                if (player.Bankroll < currentPropertySpace.BuyingPrice)
                {
                    this.DrawEngine.DrawText(40, 30, "Not Enough Money To Buy The Property");
                }
                else
                {
                    player.Bankroll = player.Bankroll - (int)currentPropertySpace.BuyingPrice;
                    player.AddSpace(currentPropertySpace);
                    currentPropertySpace.Owned = true;
                }
            }
        }
Exemplo n.º 2
0
 public void AddSpace(PurchasableSpace boughtProperty)
 {
     listOfProperties.Add(boughtProperty);
 }