/** * Called when gameButton2 was clicked, it analyses the game situation (using GameState attribute) * and then handles the click button accordingly. */ private void Button2_action() { if (GameState == GameStage.NO_ACTION) { return; } Card card = propertyManager .CardAt(gameplan.PlayerPosition(currentPlayer)); GameStage state = GameState; GameState = GameStage.NO_ACTION; switch (state) { case GameStage.DICE: SaveButton_action(); GameState = GameStage.DICE; break; case GameStage.NO_FUNDS_PAY: window.ShowMortgagedProperties(propertyManager.GetMortgagedProperties(currentPlayer, false), true); GameState = GameStage.MORTGAGE_TAKE; break; case GameStage.WHAT_NEXT: window.ShowMortgageMenu(); GameState = GameStage.MORTGAGE_MENU; break; case GameStage.TRADE_CONFIRM: window.ShowPlayerInfo(currentPlayer); window.ShowMessage("Your offer was declined!"); Thread.Sleep(2000); break; case GameStage.MORTGAGE_MENU: window.ShowMortgagedProperties(propertyManager.GetMortgagedProperties(currentPlayer, true), false); GameState = GameStage.MORTGAGE_PAY; break; default: break; } if (GameState == GameStage.NO_ACTION) { ShowWhatNext(currentPlayer); } if (currentPlayer is AIPlayer) { AIDecider.PlayTurn((AIPlayer)currentPlayer, window, this, propertyManager .CardAt(gameplan.PlayerPosition(currentPlayer))); } }
/** * The cosntructor. Prepares the game, assigns/creates its helping classes/data manipulators. */ public Game(Player[] players, Monopoly window) { this.players = players; GameState = GameStage.DICE; this.window = window; //bgw = new BackgroundWorker(); colorGroups = new int[, ] { { 0, 0, 0 }, { 255, 51, 51 }, { 0, 128, 255 }, { 152, 76, 0 }, { 255, 153, 51 }, { 255, 102, 255 }, { 0, 0, 204 }, { 0, 204, 102 }, { 255, 255, 51 } }; currentPlayer = players[playerTurnPointer]; riskCardManager = new RiskCardManager(); treasureCardManager = new TreasureCardManager(); propertyManager = new Cards.PropertyManager(); gameplan = new Gameplan(players, propertyManager.GetFieldTypes()); window.ShowPlayerInfo(currentPlayer); window.Load += OnLoad; window.Enabled = true; }