/** * Called when gameButton1 was clicked, it analyses the game situation (using GameState attribute) * and then handles the click button accordingly. */ private void Button1_action() { if (GameState == GameStage.NO_ACTION) { return; } window.Enabled = false; Card card = propertyManager .CardAt(gameplan.PlayerPosition(currentPlayer)); Player owner = propertyManager.WhoOwns(card); GameStage state = GameState; GameState = GameStage.NO_ACTION; switch (state) { case GameStage.DICE: window.HideButton(); RollDice(); break; case GameStage.AWAITING_PURCHASE: propertyManager.AddOwnership(card, currentPlayer); currentPlayer.Money -= card.Cost; break; case GameStage.AWAITING_RENT: float money = card.GetPayment(); currentPlayer.Money -= money; owner.Money += money; break; case GameStage.AWAITING_UPGRADE: PropertyCard c2 = (PropertyCard)card; window.DrawApartment( gameplan.GetCoordsOfNextApartment( gameplan.PlayerPosition( currentPlayer), c2.Apartments)); c2.AddApartment(); currentPlayer.Money -= c2.ApartmentCost; break; case GameStage.NO_FUNDS_PAY: RemovePlayer(); NextPlayer(); break; case GameStage.WHAT_NEXT: window.ShowTradeOptions(propertyManager .GetTradeOptions(currentPlayer), currentPlayer); GameState = GameStage.TRADE_OFFER; break; case GameStage.TRADE_OFFER: MakeTradeOffer(); break; case GameStage.TRADE_CONFIRM: propertyManager.ChangeOwner(currentPlayer, selectedItem, window.GetOfferedMoney()); break; case GameStage.MORTGAGE_MENU: window.ShowMortgagedProperties(propertyManager.GetMortgagedProperties(currentPlayer, false), true); GameState = GameStage.MORTGAGE_TAKE; break; case GameStage.MORTGAGE_TAKE: TakeMortgage(); break; case GameStage.MORTGAGE_PAY: PayMortgageOff(); break; case GameStage.HOLIDAY: NextPlayer(); break; default: Console.Write("An unexpected error occurred! " + GameState); break; } if (GameState == GameStage.NO_ACTION) { ShowWhatNext(currentPlayer); } window.Update(); if (currentPlayer is AIPlayer) { AIDecider.PlayTurn((AIPlayer)currentPlayer, window, this, propertyManager .CardAt(gameplan.PlayerPosition(currentPlayer))); } window.Enabled = true; }