Example #1
0
        /***************************************************************************************
         *
         *                     Robber Related Functions Goes Below Here
         *
         ***************************************************************************************/
        //Purpose:  Handle all functionality for the AI to move the Robber
        //Params:   px - the Player that is moving the Robber
        //          game - the overall game object
        //Return:   None
        public void handleRobber(Player px, SettlersOfCatan game)
        {
            //Get the Player with the most victory points
            Player highestOpponent = highestScoringOpponent(px.playerNumber, game.players);
            //Get a list of possible locations to move the Robber to
            List<GameHex> locations = possibleLocations(game, px.playerNumber, highestOpponent, false);

            //Randomly pick one of those locations
            Random rdm = new Random();
            game.gameBoard.setRobber(locations[rdm.Next(0, locations.Count())]);

            //Steal resource card
            int resourceType = px.stealRandomCard(highestOpponent);
            px.incResource(resourceType);

            px.SetBuildBools();
            px.ResourceSum();
        }