Exemple #1
0
        public void InitializeTest()
        {
            Game = new MonopolyGame.MonopolyGame(
                Players,
                Dices,
                BankInitialMoney,
                PlayersInitialMoney,
                BoardParams,
                CellsData,
                ChanceCardData,
                CommunityCardData,
                LandCardData,
                LinkCellToCardData

                );

            FirstPlayer = Players[0];
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //MonopolyPlayer mplayer = new MonopolyPlayer(1, "player 1");
            //Dictionary<MoneyType, int> init = new Dictionary<MoneyType, int>();
            //init[MoneyType.Ten] = 4;
            //init[MoneyType.One] = 10;
            //init[MoneyType.Five] = 2;
            //init[MoneyType.Twenty] = 2;
            //init[MoneyType.Fifty] = 2;
            //mplayer.Receive(init);

            //Dictionary<PropertyType, int> prices = new Dictionary<PropertyType, int>();
            //prices[PropertyType.House] = 100;
            //prices[PropertyType.Hotel] = 500;

            //Dictionary<int, int> rents = new Dictionary<int, int>();

            //rents[1] = 10;
            //rents[2] = 20;
            //rents[3] = 30;
            //rents[4] = 40;
            //rents[5] = 50;

            //LandCell cell = new LandCell(2, 2, 1, 1, "Mediterranian Avenue", "Mediterranian Avenue", 100, LandType.State);
            //LandCard mediteranianCard = new LandCard("Mediterranian Avenue", prices, rents, 50);

            //mplayer.BuyLand(mediteranianCard, cell);
            //Console.WriteLine(mplayer.LandCards.Count);
            //Console.ReadKey();

            // Welcome message
            Console.WriteLine("MONOPOLY GAME");
            Console.WriteLine("=============");
            Console.WriteLine();

            List <MonopolyPlayer> playerList = new List <MonopolyPlayer>();
            int    playerCount = -1;
            string resp;

            while (playerCount < 1 || playerCount > 4)
            {
                Console.Write("How many players? (1-4) ");
                resp        = Console.ReadLine();
                playerCount = int.Parse(resp);
            }

            for (int i = 0; i < playerCount; i++)
            {
                Console.Write("Enter name for Player " + (i + 1) + " : ");
                resp = Console.ReadLine();
                playerList.Add(new MonopolyPlayer(i + 1, resp));
            }

            Players = playerList.ToArray();

            Console.Clear();

            // Welcome message
            Console.WriteLine("MONOPOLY GAME");
            Console.WriteLine("=============");
            Console.WriteLine();

            MonopolyGame Game = new MonopolyGame(
                Players,
                Dices,
                BankInitialMoney,
                PlayersInitialMoney,
                BoardParams,
                CellsData,
                ChanceCardData,
                CommunityCardData,
                LandCardData,
                LinkCellToCardData
                );

            Thread main = new Thread(delegate() { Game.RunGame(); });

            main.Start();

            Thread.Sleep(1000);

            while (main.IsAlive)
            {
                Player player = null;
                while (main.IsAlive)
                {
                    Console.WriteLine("Select player to run turn:");
                    foreach (Player p in Players)
                    {
                        Console.WriteLine(p.Id + " - " + p.Username);
                    }

                    Console.Write("Enter ID :");
                    resp = Console.ReadLine();
                    int playerId = int.Parse(resp);

                    foreach (Player p in Players)
                    {
                        if (p.Id == playerId)
                        {
                            player = p;
                            break;
                        }
                    }

                    Console.WriteLine("Selected player :" + player.Username);
                    Game.RunTurn(player);
                }
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }