Пример #1
0
 public void payRent(ListSpaces B, int dices)
 {
     if (B.getSpace(position) is Propriety)
     {
         Propriety prop = (Propriety)B.getSpace(position);
         if (prop.possessed)
         {
             if (prop.pl == this)
             {
                 Console.WriteLine("This is your propriety, you're at home.");
             }
             else
             {
                 Console.WriteLine("This propriety is owned by " + prop.pl.name + ". You have to pay a rent !");
                 int money = 0;
                 if (prop is Company)
                 {
                     Company comp      = (Company)prop;
                     int     n_of_comp = comp.pl.list_pr.number_of_companies();
                     if (n_of_comp == 1)
                     {
                         money = 4 * dices;
                     }
                     else
                     {
                         money = 10 * dices;
                     }
                 }
                 if (prop is Station)
                 {
                     Station stat      = (Station)prop;
                     int     n_of_stat = stat.pl.list_pr.number_of_stations();
                     if (n_of_stat == 1)
                     {
                         money = stat.rent;
                     }
                     if (n_of_stat == 2)
                     {
                         money = stat.rent2stations;
                     }
                     if (n_of_stat == 3)
                     {
                         money = stat.rent3stations;
                     }
                     if (n_of_stat == 4)
                     {
                         money = stat.rent4stations;
                     }
                 }
                 if (prop is Street)
                 {
                     Street st = (Street)prop;
                     if (st.pl.list_pr.allColors(st.color))
                     {
                         money = st.rent * 2;
                         if (st.house == 1)
                         {
                             money = st.rent1house;
                         }
                         if (st.house == 2)
                         {
                             money = st.rent2house;
                         }
                         if (st.house == 3)
                         {
                             money = st.rent3house;
                         }
                         if (st.house == 4)
                         {
                             money = st.rent4house;
                             if (st.hotel == 1)
                             {
                                 money = st.renthotel;
                             }
                         }
                     }
                     else
                     {
                         money = st.rent;
                     }
                 }
                 Console.WriteLine("You have to pay " + money + " euros to " + prop.pl.name);
                 account          = account - money;
                 prop.pl.account += money;
             }
         }
     }
 }
Пример #2
0
 public void buyHotel(ListSpaces B)
 {
     if (list_pr == null)
     {
         Console.WriteLine("You don't owe any propriety, you can't buy a hotel !");
     }
     else
     {
         Console.WriteLine("Enter the name of the street where you want to buy a hotel :");
         string prop_name = Console.ReadLine();
         while (!(B.onList(prop_name, 40)))
         {
             Console.WriteLine("This propriety is not in the game board !");
             Console.WriteLine("Please write the space name correctly.");
             Console.WriteLine("If you want to leave, press 'z'");
             prop_name = Console.ReadLine();
             if (prop_name == "z")
             {
                 break;
             }
         }
         if ((B.onList(prop_name, 40)))
         {
             while (!(list_pr.onList(prop_name, list_pr.Size)))
             {
                 Console.WriteLine("You don't possess this propriety !");
                 Console.WriteLine("Your proprieties are " + list_pr);
                 Console.WriteLine("Please write the propriety name correctly.");
                 Console.WriteLine("If you want to leave, press 'z'");
                 prop_name = Console.ReadLine();
                 if (prop_name == "z")
                 {
                     break;
                 }
                 while (!(B.onList(prop_name, 40)))
                 {
                     Console.WriteLine("This propriety is not in the game board !");
                     Console.WriteLine("Please write the space name correctly.");
                     Console.WriteLine("If you want to leave, press 'z'");
                     prop_name = Console.ReadLine();
                     if (prop_name == "z")
                     {
                         break;
                     }
                 }
             }
             if ((B.onList(prop_name, 40)) && (list_pr.onList(prop_name, list_pr.Size)))
             {
                 Propriety test = (Propriety)B.getSpace(B.getSpacePosition(prop_name));
                 if (test is Street)
                 {
                     Street test1 = (Street)B.getSpace(B.getSpacePosition(prop_name));
                     if (test1.house != 4)
                     {
                         Console.WriteLine("This street already doesn't have 4 houses, you can't buy a hotel !");
                     }
                     else
                     {
                         if (test1.hotel == 1)
                         {
                             Console.WriteLine("This street already have 1 hotel, you can't buy another one !");
                         }
                         else
                         {
                             Console.WriteLine("Do you want to buy a hotel in this propriety : " + test1.name + " ?");
                             Console.WriteLine("The price of a hotel is " + test1.hprice());
                             Console.WriteLine("Press 1 for yes 0 for no");
                             int resp = Convert.ToInt32(Console.ReadLine());
                             while (resp != 0 && resp != 1)
                             {
                                 Console.WriteLine("Please enter a correct awnser.");
                                 Console.WriteLine("Press 1 for yes or 0 for no. ");
                                 resp = Convert.ToInt32(Console.ReadLine());
                             }
                             if (resp == 1)
                             {
                                 if (account >= test1.hprice())
                                 {
                                     account = account - test1.hprice();
                                     test1.hotel++;
                                     B.changeSpace(B.getSpacePosition(prop_name), test1);
                                 }
                                 else
                                 {
                                     Console.WriteLine("You don't have enough money to buy this hotel !");
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     Console.WriteLine("You can't put a hotel in this propriety, this isn't a street !");
                 }
             }
         }
     }
 }
Пример #3
0
        static ListSpaces CreateBoard()
        {
            // Creation of the game spaces ---------------------------------

            //Proprieties
            Spaces pr1  = new Street("Boulevard de Belleville", 60, "brown", 2, 10, 30, 90, 160, 250);
            Spaces pr2  = new Street("Rue Lecourbe", 80, "brown", 4, 20, 60, 180, 320, 450);
            Spaces pr3  = new Street("Rue de Vaugirard", 100, "sky_blue", 6, 30, 90, 270, 400, 550);
            Spaces pr4  = new Street("Rue de Courcelles", 100, "sky_blue", 6, 30, 90, 270, 400, 550);
            Spaces pr5  = new Street("Avenue de la Republique", 120, "sky_blue", 8, 40, 100, 300, 450, 600);
            Spaces pr6  = new Street("Boulevard de la Villette", 140, "pink", 10, 50, 150, 450, 625, 750);
            Spaces pr7  = new Street("Avenue de Neuilly", 140, "pink", 10, 50, 150, 450, 625, 750);
            Spaces pr8  = new Street("Rue de Paradis", 160, "pink", 12, 60, 180, 500, 700, 900);
            Spaces pr9  = new Street("Avenue Mozart", 180, "orange", 14, 70, 200, 550, 750, 950);
            Spaces pr10 = new Street("Boulevart Saint-Michel", 180, "orange", 14, 70, 200, 550, 750, 950);
            Spaces pr11 = new Street("Place Pigalle", 200, "orange", 16, 80, 220, 600, 800, 1000);
            Spaces pr12 = new Street("Avenue Matignon", 220, "red", 18, 90, 250, 700, 875, 1050);
            Spaces pr13 = new Street("Boulevard Malesherbes", 220, "red", 18, 90, 250, 700, 875, 1050);
            Spaces pr14 = new Street("Avenue Henri-Martin", 240, "red", 20, 100, 300, 750, 925, 1100);
            Spaces pr15 = new Street("Faubourg Saint-Honoré", 260, "yellow", 22, 110, 330, 800, 975, 1150);
            Spaces pr16 = new Street("Place de la Bourse", 260, "yellow", 22, 110, 330, 800, 975, 1150);
            Spaces pr17 = new Street("Rue de la Fayette", 280, "yellow", 24, 120, 360, 850, 1025, 1200);
            Spaces pr18 = new Street("Avenue De Breteuil", 300, "green", 26, 130, 390, 900, 1100, 1275);
            Spaces pr19 = new Street("Avenue de Foch", 300, "green", 26, 130, 390, 900, 1100, 1275);
            Spaces pr20 = new Street("Boulevard des Capucines", 320, "green", 28, 150, 450, 1000, 1200, 1400);
            Spaces pr21 = new Street("Avenue des Champs-Elysées", 350, "blue", 35, 175, 500, 1100, 1300, 1500);
            Spaces pr22 = new Street("Rue de la Paix", 400, "blue", 50, 200, 600, 1400, 1700, 2000);

            // Train Stations
            Spaces tr1 = new Station("Gare Montparnasse", 200, 25, 50, 100, 200);
            Spaces tr2 = new Station("Gare de Lyon", 200, 25, 50, 100, 200);
            Spaces tr3 = new Station("Gare du Nord", 200, 25, 50, 100, 200);
            Spaces tr4 = new Station("Gare Saint-Lazare", 200, 25, 50, 100, 200);

            // Public Service Companies
            Spaces pc1 = new Company("Electric Company", 150, 0);
            Spaces pc2 = new Company("Water Works", 150, 0);

            // Special Spaces
            Spaces ss1  = new SpecialSpace("Start");
            Spaces ss2  = new SpecialSpace("Community");
            Spaces ss3  = new SpecialSpace("Tax");
            Spaces ss4  = new SpecialSpace("Chance");
            Spaces ss5  = new SpecialSpace("PrisonVisit");
            Spaces ss6  = new SpecialSpace("Community");
            Spaces ss7  = new SpecialSpace("Parking");
            Spaces ss8  = new SpecialSpace("Chance");
            Spaces ss9  = new SpecialSpace("GtP");
            Spaces ss10 = new SpecialSpace("Community");
            Spaces ss11 = new SpecialSpace("Chance");
            Spaces ss12 = new SpecialSpace("LuxeTax");

            // Creation of game board --------------------------------------------
            ListSpaces Board = new ListSpaces(ss1);

            Board.AddTail(pr1);
            Board.AddTail(ss2);
            Board.AddTail(pr2);
            Board.AddTail(ss3);
            Board.AddTail(tr1);
            Board.AddTail(pr3);
            Board.AddTail(ss4);
            Board.AddTail(pr4);
            Board.AddTail(pr5);
            Board.AddTail(ss5);
            Board.AddTail(pr6);
            Board.AddTail(pc1);
            Board.AddTail(pr7);
            Board.AddTail(pr8);
            Board.AddTail(tr2);
            Board.AddTail(pr9);
            Board.AddTail(ss6);
            Board.AddTail(pr10);
            Board.AddTail(pr11);
            Board.AddTail(ss7);
            Board.AddTail(pr12);
            Board.AddTail(ss8);
            Board.AddTail(pr13);
            Board.AddTail(pr14);
            Board.AddTail(tr3);
            Board.AddTail(pr15);
            Board.AddTail(pr16);
            Board.AddTail(pc2);
            Board.AddTail(pr17);
            Board.AddTail(ss9);
            Board.AddTail(pr18);
            Board.AddTail(pr19);
            Board.AddTail(ss10);
            Board.AddTail(pr20);
            Board.AddTail(tr4);
            Board.AddTail(ss11);
            Board.AddTail(pr21);
            Board.AddTail(ss12);
            Board.AddTail(pr22);
            pr22.next = ss1;
            return(Board);
        }