Ejemplo n.º 1
0
        static ListPlayer CreatePlayers(int nb_pl)
        {
            Console.WriteLine("Enter the name of player 0");
            string     name = Console.ReadLine();
            Player     p    = new Player(name);
            ListPlayer LiPl = new ListPlayer(p);

            Console.WriteLine(p);
            for (int i = 1; i < nb_pl; i++)
            {
                Console.WriteLine("Enter the name of player " + i);
                name = Console.ReadLine();
                p    = new Player(name);
                LiPl.AddTail(p);
                Console.WriteLine(p);
            }
            Console.WriteLine("Enter the position of the player who will be banker : ");
            int pos = Convert.ToInt32(Console.ReadLine());

            while (pos < 0 || pos >= nb_pl)
            {
                Console.WriteLine("Please enter a correct value ");
                Console.WriteLine("The position should be between 0 and " + (nb_pl - 1));
                pos = Convert.ToInt32(Console.ReadLine());
            }

            Banker ban = Banker.GetInstance(LiPl.getPlayer(pos));

            LiPl.getPlayer(nb_pl - 1).next = LiPl.getPlayer(0);
            return(LiPl);
        }
Ejemplo n.º 2
0
        public string getInformationPnumber(ListPlayer P)
        {
            Console.WriteLine("Enter the number of the player whom you want to have information : ");
            int pos_sp = Convert.ToInt32(Console.ReadLine());

            return(P.getPlayer(pos_sp).ToString());
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            // -------------------------Intialization-------------------------------------------------------
            ListSpaces Board = CreateBoard();

            Console.WriteLine("How many players will play this game ? ");
            Console.WriteLine("Please enter a number : ");
            int number_players = Convert.ToInt32(Console.ReadLine());

            while (number_players < 2)
            {
                Console.WriteLine("At least two players needed to start a game ! ");
                Console.WriteLine("How many players will play this game ? ");
                Console.WriteLine("Please enter a number : ");
                number_players = Convert.ToInt32(Console.ReadLine());
            }
            ListPlayer           List_of_players = CreatePlayers(number_players);
            Queue <SpecialCards> cc  = CreateChanceQueue();
            Queue <SpecialCards> ccc = CreateCommunityChestQueue();

            // ----------------------------------------------------------------------------------------------
            Game(Board, List_of_players, List_of_players.getPlayer(0), number_players, cc, ccc);
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public Player auction(ListPlayer P)
        {
            Console.Clear();
            Player pla = P.getPlayer(0);

            Console.WriteLine("This auction starts");
            Console.WriteLine("The propriety to buy is " + name);
            int    amount = 0;
            int    res    = 10;
            string n      = "";

            while (n != pla.name)
            {
                if (!(pla.in_prison))
                {
                    Console.WriteLine(pla.name + " this is you turn to auction");
                    Console.WriteLine("Do you want to bid for this propriety : " + name + " ?");
                    Console.WriteLine("The current bid is " + amount);
                    Console.WriteLine("Press 1 for yes, 0 for no");
                    res = Convert.ToInt32(Console.ReadLine());
                    while (res != 0 && res != 1)
                    {
                        Console.WriteLine("Please enter a correct awnser.");
                        Console.WriteLine("Press 1 for yes or 0 for no. ");
                        res = Convert.ToInt32(Console.ReadLine());
                    }
                    if (res == 1)
                    {
                        int  am         = 0;
                        bool bid_placed = false;
                        while (!(bid_placed) && am != 9999)
                        {
                            Console.WriteLine("Enter the amount of your bid :");
                            am = Convert.ToInt32(Console.ReadLine());
                            if (am > amount)
                            {
                                if (am <= pla.account)
                                {
                                    Console.WriteLine("You place your bid for this propriety !");
                                    amount     = am;
                                    bid_placed = true;
                                    n          = pla.name;
                                }
                                else
                                {
                                    Console.WriteLine("You don't have enough money in your account !");
                                    Console.WriteLine("Press 9999 to cancel your bid");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Your bid is lower than the current amount !");
                                Console.WriteLine("The current bid is " + amount);
                                Console.WriteLine("Press 9999 to cancel your bid");
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine(pla.name + ", you can't play be in this action because you're in prison !");
                }
                pla = pla.next;
            }
            Console.WriteLine(pla.name + " won this auction");
            Console.WriteLine("He bought " + name + " for " + amount + " euros.");
            pla.account = pla.account - amount;
            return(pla);
        }