Example #1
0
        /// <summary>
        /// This method Handle Options
        /// </summary>
        internal void HandleOptions()
        {
            // Set the Game Options
            this.GameManager = LoadGameManager();

            // if the GameManager exists
            if (this.HasGameManager)
            {
                // iterate the players
                foreach (Player player in this.GameManager.Players)
                {
                    // Find the blackJackPlayerControl at this seat number
                    BlackJackPlayerControl blackJackPlayerControl = FindBlackJackPlayerControl(player.SeatNumber);

                    // If the blackJackPlayerControl object exists
                    if (NullHelper.Exists(blackJackPlayerControl))
                    {
                        // Setup the blackJackPlayerControl
                        blackJackPlayerControl.DisplayPlayer();
                    }
                }

                // Show or hide controls based upon the number of players
                UIVisibility();
            }
        }
        /// <summary>
        /// This method is used to get the users response.
        /// </summary>
        /// <returns></returns>
        public override PlayerResponse Start(PlayerResponseControl responseControl, BlackJackPlayerControl playerControl)
        {
            // Set the ResponseControl
            this.PlayerResponseControl = responseControl;

            // Create the AllowResponses
            this.AllowedResponseTypes = new List <ResponseTypeEnum>();
            this.AllowedResponseTypes.Add(ResponseTypeEnum.Hit);
            this.AllowedResponseTypes.Add(ResponseTypeEnum.Stand);

            // Setup the Button
            this.SetupButtons();

            // position the responseControl based upon the SeatNumber
            responseControl.Location = PositionResponseControl(responseControl, playerControl);

            // Show the ResponseControl
            responseControl.Show();

            // Make sure Show toggles this
            responseControl.Visible = true;

            // return this object
            return(this.Response);
        }
Example #3
0
        /// <summary>
        /// This method returns the Player Control
        /// </summary>
        private static BlackJackPlayerControl FindPlayerControl(List <BlackJackPlayerControl> playerControls, SeatNumberEnum seatNumber)
        {
            // initial value
            BlackJackPlayerControl playerControl = null;

            // If the playerControls collection exists and has one or more items
            if (ListHelper.HasOneOrMoreItems(playerControls))
            {
                // Iterate the collection of BlackJackPlayerControl1 objects
                foreach (BlackJackPlayerControl tempPlayerControl in playerControls)
                {
                    // if this is the control being sought
                    if (tempPlayerControl.SeatNumber == seatNumber)
                    {
                        // Set the SeatNumber
                        playerControl = tempPlayerControl;

                        // break out of the loop
                        break;
                    }
                }
            }

            // return value
            return(playerControl);
        }
 /// <summary>
 /// Create a new instance of a Player object
 /// </summary>
 /// <param name="name">The name of this player</param>
 /// <param name="chips">The chips on the table for this player.</param>
 /// <param name="isComputerPlayer">Is this a human (false) or a computer player (true)</param>
 public Player(string name, double chips, bool isComputerPlayer, BlackJackPlayerControl playerControl)
 {
     // store the arguments
     this.Name             = name;
     this.Chips            = chips;
     this.IsComputerPlayer = isComputerPlayer;
     this.PlayerControl    = playerControl;
 }
Example #5
0
        /// <summary>
        /// This method shows an Action Message
        /// </summary>
        internal void ShowActionMessage(string message, SeatNumberEnum seatNumber)
        {
            // Find the playerControl
            BlackJackPlayerControl playerControl = FindBlackJackPlayerControl(seatNumber);

            // If the playerControl object exists
            if (NullHelper.Exists(playerControl))
            {
                // Show the action message
                playerControl.ShowActionMessage(message);
            }
        }
Example #6
0
        /// <summary>
        /// This method returns the Black Jack Player Control
        /// </summary>
        private BlackJackPlayerControl FindBlackJackPlayerControl(SeatNumberEnum seatNumber)
        {
            // initial value
            BlackJackPlayerControl blackJackPlayerControl = null;

            // Determine the action by the seatNumber
            switch (seatNumber)
            {
            case SeatNumberEnum.Seat1:

                // set the control
                blackJackPlayerControl = this.BlackJackPlayerControl1;

                // required
                break;

            case SeatNumberEnum.Seat2:

                // set the control
                blackJackPlayerControl = this.BlackJackPlayerControl2;

                // required
                break;

            case SeatNumberEnum.Seat3:

                // set the control
                blackJackPlayerControl = this.BlackJackPlayerControl3;

                // required
                break;

            case SeatNumberEnum.Seat4:

                // set the control
                blackJackPlayerControl = this.BlackJackPlayerControl4;

                // required
                break;

            case SeatNumberEnum.Seat5:

                // set the control
                blackJackPlayerControl = this.BlackJackPlayerControl5;

                // required
                break;
            }

            // return value
            return(blackJackPlayerControl);
        }
        /// <summary>
        /// This method creates the Response Request before prompting the user for an Action.
        /// </summary>
        /// <param name="responseRequestType"></param>
        public static IPlayerResponseRequest CreatePlayerResponseRequest(ResponseRequestTypeEnum responseRequestType, PlayerResponseControl playerResponseControl, BlackJackPlayerControl blackJackPlayerControl, Options houseRules)
        {
            // initial valule
            IPlayerResponseRequest playerResponseRequest = null;

            // Determine the action by the responseRequestType
            switch (responseRequestType)
            {
            case ResponseRequestTypeEnum.PlaceBet:

                // Create a placeBetResponse
                playerResponseRequest = new PlaceBetResponseRequest(houseRules);

                // required
                break;

            case ResponseRequestTypeEnum.PlayHand:

                // Create a placeBetResponse
                playerResponseRequest = new PlayHandResponseRequest(houseRules);

                // required
                break;

            case ResponseRequestTypeEnum.Insurance:

                // Create a placeBetResponse
                playerResponseRequest = new TakeInsuranceResponseRequest(houseRules);

                // required
                break;
            }

            // if the request exists
            if (NullHelper.Exists(playerResponseRequest))
            {
                // Setup the controls
                playerResponseRequest.BlackJackPlayerControl = blackJackPlayerControl;
                playerResponseRequest.PlayerResponseControl  = playerResponseControl;
            }

            // return value
            return(playerResponseRequest);
        }
Example #8
0
        /// <summary>
        /// This method is used to load a GameManager object from the values from this object
        /// so that the controls be can be loaded when the program starts
        /// </summary>
        /// <returns></returns>
        public static GameManager Export(SecureUserData security, List <BlackJackPlayerControl> playerControls, MainForm table)
        {
            // initial value
            GameManager gameManager = null;

            // local
            BlackJackPlayerControl playerControl = null;

            // If the security object exists
            if (NullHelper.Exists(security, playerControls, table))
            {
                // Create a new instance of a 'GameManager' object.
                gameManager = new GameManager(NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1), table);

                // create a houseRules object
                Options houseRules = new Options();

                // set the properties from this form
                houseRules.AllowDoubleDown              = security.AllowDoubleDown;
                houseRules.AllowDoubleOnSplit           = security.AllowDoubleOnSplit;
                houseRules.AllowDoubleOnTenOrElevenOnly = security.AllowDoubleOnTenOrElevenOnly;
                houseRules.AllowInsurance   = security.AllowInsurance;
                houseRules.AllowResplitAces = security.AllowResplitAces;
                houseRules.AllowSplit       = security.AllowSplit;
                houseRules.AllowSplitAces   = security.AllowSplitAces;
                houseRules.AllowSurrender   = security.AllowSurrender;
                houseRules.ComputerPlayersUnlimitedRebuys = security.ComputerPlayersUnlimitedRebuys;
                houseRules.DealerMustHitSoft17            = security.DealerMustHitSoft17;
                houseRules.DefaultBankRoll         = security.DefaultBankRoll;
                houseRules.DefaultComputerBankRoll = security.DefaultComputerBankRoll;
                houseRules.GameSpeed = security.GameSpeed;
                houseRules.HumanPlayerUnlimitedRebuys = security.HumanPlayerUnlimitedRebuys;
                houseRules.NumberDecks = security.NumberDecks;
                houseRules.Penetration = security.Penetration;
                houseRules.SaveSettingsOnThisComputer = security.SaveSettingsOnThisComputer;
                houseRules.TableMaximum = security.TableMaximum;
                houseRules.TableMinimum = security.TableMinimum;

                // Create a list of players
                List <Player> players = new List <Player>();

                // if Player1's Name is set that is consider playing
                if (TextHelper.Exists(security.Player1Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat1);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 1
                        Player player1 = new Player(security.Player1Name, security.Player1Chips, security.Player1IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player1.SeatNumber = SeatNumberEnum.Seat1;

                        // Is Player1 Sitting Out
                        player1.SittingOut = security.Player1SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player1CountingSystem;
                        player1.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player1);
                    }
                }

                // if Player2's Name is set that is consider playing
                if (TextHelper.Exists(security.Player2Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat2);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 2
                        Player player2 = new Player(security.Player2Name, security.Player2Chips, security.Player2IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player2.SeatNumber = SeatNumberEnum.Seat2;

                        // Is Player2 Sitting Out
                        player2.SittingOut = security.Player2SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player2CountingSystem;
                        player2.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player2);
                    }
                }

                // if Player3's Name is set that is consider playing
                if (TextHelper.Exists(security.Player3Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat3);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 3
                        Player player3 = new Player(security.Player3Name, security.Player3Chips, security.Player3IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player3.SeatNumber = SeatNumberEnum.Seat3;

                        // Is Player3 Sitting Out
                        player3.SittingOut = security.Player3SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player3CountingSystem;
                        player3.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player3);
                    }
                }

                // if Player4's Name is set that is consider playing
                if (TextHelper.Exists(security.Player4Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat4);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 4
                        Player player4 = new Player(security.Player4Name, security.Player4Chips, security.Player4IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player4.SeatNumber = SeatNumberEnum.Seat4;

                        // Is Player4 Sitting Out
                        player4.SittingOut = security.Player4SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player4CountingSystem;
                        player4.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player4);
                    }
                }

                // if Player5's Name is set that is consider playing
                if (TextHelper.Exists(security.Player5Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat5);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 5
                        Player player5 = new Player(security.Player5Name, security.Player5Chips, security.Player5IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player5.SeatNumber = SeatNumberEnum.Seat5;

                        // Is Player5 Sitting Out
                        player5.SittingOut = security.Player5SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player5CountingSystem;
                        player5.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player5);
                    }
                }

                // set the HouseRules & players
                gameManager.HouseRules = houseRules;
                gameManager.Players    = players;

                // if the HouseRules exist
                if (gameManager.HasHouseRules)
                {
                    // create
                    BlackJackCardValueBase blackJackCardValueBase = new BlackJackCardValueBase();

                    // Set the times to shuffle
                    int timesToShuffle = NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1);

                    // Create the Shuffler
                    gameManager.Shuffler = new RandomShuffler(houseRules.NumberDecks, blackJackCardValueBase, 0);
                }
            }

            // return value
            return(gameManager);
        }
Example #9
0
        /// <summary>
        /// This method returns the Response Control
        /// </summary>
        protected Point PositionResponseControl(PlayerResponseControl responseControl, BlackJackPlayerControl playerControl)
        {
            // Create the point
            Point point = new Point();

            // If the PlayerControl object exists
            if (NullHelper.Exists(playerControl, responseControl))
            {
                // get half of this control
                int halfPlayerControl   = playerControl.Width / 2;
                int halfResponseControl = responseControl.Width / 2;
                int adjustment          = halfPlayerControl - halfResponseControl;

                // Set the Horizontal Position
                point.X = playerControl.Left + adjustment;

                // Set the Vertical Position
                point.Y = playerControl.Top + playerControl.Height - playerControl.GetChipsPanelHeight() - playerControl.GetPlayerInfoPanelHeight() + responseControl.Height;
            }

            // return value
            return(point);
        }
Example #10
0
 /// <summary>
 /// This method is called by the GameManager to get a players response based upon the ResponseType.
 /// </summary>
 public abstract PlayerResponse Start(PlayerResponseControl responseControl, BlackJackPlayerControl playerControl);