예제 #1
0
파일: Program.cs 프로젝트: scazier/Monopoly
        public static void Start()
        {
            Console.WriteLine("\nFrise Début\n");
            Game           model      = new Game(); // Creation of the board and the players
            GameView       view       = new GameView();
            GameController controller = new GameController(model, view);

            Street Board   = model.Board;
            Player players = model.Players;
            Banker banker  = Banker.CreateBanker();
            Deck   deck    = Deck.ReadDeck();

            //Console.WriteLine(deck.toString());

            controller.initializePlayers();

            players.displayAllPlayers();
            Console.WriteLine("This is the list of the players!");
            Console.WriteLine("Press any key to start the game...");
            controller.displayGame();
            Console.ReadLine();
            Console.Clear();

            controller.playGame();
        }
예제 #2
0
파일: Player.cs 프로젝트: scazier/Monopoly
        public void AddHotel()
        {
            Banker banker = Banker.CreateBanker();

            if (this.Position.Id_buyer == this.ID)
            {
                if (GameController.AllColors(this))
                {
                    if (this.Position.Nb_house == 4)
                    {
                        banker.Money += this.Position.PriceHotel;
                        this.Money   -= this.Position.PriceHotel;
                        banker.Operations.Add(new Exchange(this.ID, "+" + this.Position.PriceHotel));
                        this.Position.Nb_house = 0;
                        this.Position.Hotel    = true;
                    }
                }
            }
        }
예제 #3
0
파일: Player.cs 프로젝트: scazier/Monopoly
 public void Buy()
 {
     if (this.Position.Basic_price != -1)
     {
         if (this.Position.Id_buyer == 0)
         {
             if (this.Money >= this.Position.Basic_price)
             {
                 Banker banker = Banker.CreateBanker();
                 // It's the same banker as in the class Game because this class is a singleton pattern
                 this.Money   -= this.Position.Basic_price; // Update the player money
                 banker.Money += this.Position.Basic_price; // Update the banker money
                 banker.Operations.Add(new Exchange(this.ID, "+" + Convert.ToString(this.Position.Basic_price)));
                 this.Position.Id_buyer = this.ID;
                 this.Id_purchased.Add(this.Position.ID);
             }
         }
     }
 }
예제 #4
0
파일: Player.cs 프로젝트: scazier/Monopoly
 public void AddHouse()
 {
     if (this.Position.Id_buyer == this.ID)
     {
         if (GameController.AllColors(this))
         // If all the properties with the same colors are our propeties we can add a house
         {
             if (!this.Position.Hotel)
             {
                 Banker banker = Banker.CreateBanker();
                 if (this.Position.Nb_house == 0 ||  (this.Position.Nb_house < 4 && GameController.UniformConstruction(this)))
                 {
                     this.Position.Nb_house++;
                     this.Money   -= this.Position.PriceHouse;
                     banker.Money += this.Position.PriceHouse;
                     banker.Operations.Add(new Exchange(this.ID, "+" + this.Position.PriceHouse));
                 }
             }
         }
     }
 }
예제 #5
0
        public static void CheckBuy()
        {
            bool   result = true;
            Player pl     = new Player(0, "Test");

            pl.Position = Game.CreateBoard();
            while (pl.Position.Basic_price == -1)
            {
                pl.Position = pl.Position.next;
            }
            int    diff   = pl.Money - pl.Position.Basic_price;
            Banker banker = Banker.CreateBanker();

            pl.Buy();

            if (pl.Money != diff || banker.Money != pl.Position.Basic_price ||  pl.Position.Id_buyer != pl.ID ||  pl.Id_purchased[0] != pl.Position.ID)
            {
                result = false;
            }

            displayResult("Buy", result);
        }