Ejemplo n.º 1
0
 public static void placePlayersInCorners(GUI gui)
 {
     GamePlayerFunctions.generalButtonClick(gui, gui.button1, 1); //replace with actions not gen button clicks
     GamePlayerFunctions.advanceTurn(gui);
     GamePlayerFunctions.generalButtonClick(gui, gui.button8, 8);
     GamePlayerFunctions.advanceTurn(gui);
     GamePlayerFunctions.generalButtonClick(gui, gui.button57, 57);
     GamePlayerFunctions.advanceTurn(gui);
     GamePlayerFunctions.generalButtonClick(gui, gui.button64, 64);
     GamePlayerFunctions.advanceTurn(gui);
 }
Ejemplo n.º 2
0
        public static void processGameLoop(GUI gui)
        {
            InterfaceControls.DisableControls(gui);
            ButtonControls.cursorsFlag = true;
            gui.Cursor = Cursors.WaitCursor;
            aiFlag     = true;
            advanceTurn(gui); //set current turn to player turn

            while (PlayerResources.gameState.currentPlayer != 1)
            {
                //for each player, determine the possible actions they can take,
                //randomly do one of the actions, and then advance to the next turn
                List <string> possibleActions;

                //retrieve possible actions that the player can do
                possibleActions = PlayerResources.gameState.returnPossibleActions(PlayerResources.gameState.selectCurrentPlayer());

                //if there are no possible actions, omit the step (the player is broke)
                if (possibleActions.Count != 0)
                {
                    while (availableAction == true)
                    {
                        //from possible actions, pick one and do it
                        int    r            = PlayerResources.rndAction.Next(possibleActions.Count);
                        string randomAction = (string)possibleActions[r];

                        //if the choice was to buy a development, do the appropriate action and then advance turn

                        if (randomAction == "BUY")
                        {
                            List <string> possibleNeighbors = PlayerResources.gameState.getAllNeighbors(PlayerResources.gameState.selectCurrentPlayer);
                            int           randomIndex       = PlayerResources.rndTile.Next(possibleNeighbors.Count);
                            string        randomButton      = (string)possibleNeighbors[randomIndex];
                            int           index             = Convert.ToInt32(string.Join(null, System.Text.RegularExpressions.Regex.Split(randomButton, "[^\\d]")));

                            if (PlayerResources.gameState.gameBoard.getBoard().ElementAt(index - 1).getOccupier() == 0)
                            {
                                //generate a button click with the returned button
                                Button button = gui.buttonList.Find(item => item.Name == randomButton);
                                GamePlayerFunctions.generalButtonClick(gui, button, index);
                            }
                            else
                            {
                                availableAction = false;
                            }
                        }
                    }
                }

                //now that the player has done their action, advance the turn
                advanceTurn(gui);
            }

            aiFlag = false;
            ButtonControls.cursorsFlag = false;

            PlayerResources.gameState.addIncomesForAllPlayers();
            gui.creditsBox.Text = "" + PlayerResources.gameState.selectCurrentPlayer().goldCount;
            InterfaceControls.EnableControls(gui);
            gui.Cursor = Cursors.Default;
        }
Ejemplo n.º 3
0
 public static void endTurnButtonClick(GUI gui, object sender, EventArgs e)
 {
     SoundEffectPlayer.playSoundEffect(Properties.Resources.end_turn);
     GamePlayerFunctions.processGameLoop(gui); //will compute turns for players 2-4, then return to the player
 }