Example #1
0
        public void LandOnCity(Player activePlayer, CityCase activeCase)
        {
            List <string> answers = new List <string>();

            answers.Add("Yes");
            answers.Add("No");
            int choix = 0;

            if (activeCase.Owner == null)
            {
                Console.WriteLine("You landed on " + activeCase.Name + ", do you want to buy it ?"
                                  + "\nYour balance is " + activePlayer.Balance + ". Price is " + activeCase.PurchasePrice);
                Texte(0, answers);
                choix = DeplacementFleches(choix, answers, ("You landed on " + activeCase.Name + ", do you want to buy it ?"
                                                            + "\nYour balance is " + activePlayer.Balance + ". Price is " + activeCase.PurchasePrice));
                switch (choix)
                {
                case 1:
                    if (activePlayer.Balance >= activeCase.PurchasePrice)
                    {
                        activeCase.Owner = activePlayer;
                        activePlayer.BuyCase(activeCase);
                        Console.WriteLine("Congratulations, you're the new owner of " + activeCase.Name);
                        myBoard.Notify(myBoard.Players[myBoard.ActivePlayer]);
                        System.Threading.Thread.Sleep(2000);
                        Console.Clear();
                        NextAction();
                    }
                    else
                    {
                        Console.WriteLine("Balance is too low to purchase this case");
                        System.Threading.Thread.Sleep(2000);
                        Console.Clear();
                        NextAction();
                    }
                    break;

                case 2:
                    Console.Clear();
                    NextAction();
                    break;
                }
            }
            else
            {
                if (activeCase.Owner.Name.Equals(activePlayer.Name))
                {
                    Console.WriteLine("You landed on your property.");
                    System.Threading.Thread.Sleep(2000);
                    NextAction();
                }
                else
                {
                    Console.WriteLine("You landed on " + activeCase.Owner.Name + "property.\n You owe him " + activeCase.ActiveRent);
                    System.Threading.Thread.Sleep(2000);
                    activePlayer.Balance     -= activeCase.ActiveRent;
                    activeCase.Owner.Balance += activeCase.ActiveRent;
                    Console.Clear();
                    NextAction();
                }
            }
        }