/// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method returns the Player Response Control
        /// </summary>
        internal PlayerResponseControl GetPlayerResponseControl()
        {
            // initial value
            PlayerResponseControl responseControl = this.PlayerResponseControl;

            // return value
            return(responseControl);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method returns the For Insurance
        /// </summary>
        internal void PromptForInsurance(IPlayerResponseRequest takeInsuranceRequest)
        {
            // verify this player is in this hand (has a hand and the GameMagager.Shuffler exists)
            bool isInHand = IsInHand();

            // If this player is dealt in
            if ((isInHand) && (this.HasPlayerControl) && (this.PlayerControl.HasTable))
            {
                // if this is a computer player
                if (this.IsComputerPlayer)
                {
                    // Find the Shuffler to use
                    RandomShuffler chipShuffler = this.PlayerControl.Table.ChipShuffler;

                    // if the Shuffler exists
                    if ((chipShuffler.HasRandomIntStorage) && (chipShuffler.CanPullNextItem()))
                    {
                        // get a randomIntValue
                        int randomIntValue = chipShuffler.PullNextItem(false);

                        // Take Insurance if the random value is an even number
                        bool takeInsurance = ((randomIntValue % 2) == 0);

                        // Send the response
                        PlayerResponse response = null;

                        // if this player choose to takeInsurance
                        if (takeInsurance)
                        {
                            // the player choose to take insurance

                            // Create a response this player took insurance
                            response = new PlayerResponse(ResponseTypeEnum.Insurance, this.CurrentHand.AmountWagered / 2);

                            // This was an insurance request
                            response.ResponseRequestType = ResponseRequestTypeEnum.Insurance;

                            // Get a reference to the PlayerResponseControl
                            PlayerResponseControl playerResponseControl = this.PlayerControl.Table.GetPlayerResponseControl();

                            // If the playerResponseControl object exists
                            if (NullHelper.Exists(playerResponseControl))
                            {
                                // If the value for the property playerResponseControl.HasSendResponseCallBack is true
                                if (playerResponseControl.HasSendResponseCallBack)
                                {
                                    // Send the response back
                                    playerResponseControl.SendResponseCallBack(response);
                                }
                            }
                        }
                        else
                        {
                            // the player declined taking insurance

                            // Create a response this player took insurance
                            response = new PlayerResponse(ResponseTypeEnum.No);

                            // This was an insurance request
                            response.ResponseRequestType = ResponseRequestTypeEnum.Insurance;

                            // Get a reference to the PlayerResponseControl
                            PlayerResponseControl playerResponseControl = this.PlayerControl.Table.GetPlayerResponseControl();

                            // If the playerResponseControl object exists
                            if (NullHelper.Exists(playerResponseControl))
                            {
                                // If the value for the property playerResponseControl.HasSendResponseCallBack is true
                                if (playerResponseControl.HasSendResponseCallBack)
                                {
                                    // Send the response back
                                    playerResponseControl.SendResponseCallBack(response);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // This is a human so start the ResponseRequest
                    takeInsuranceRequest.Start(this.PlayerControl.Table.GameManager.ResponseControl, this.PlayerControl);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This method returns the For Bet
        /// </summary>
        internal void PromptForBet(PlayerResponseControl responseControl, Hand hand, Options houseRules)
        {
            // locals
            PlaceBetResponseRequest placeBetResponseRequest = null;
            PlayerResponse          playerResponse          = null;
            double amountWagered = 0;

            // If the responseControl object exists
            if ((NullHelper.Exists(responseControl)) && (responseControl.HasResponseRequest))
            {
                // get a local copy so the type is shorter
                placeBetResponseRequest = responseControl.ResponseRequest as PlaceBetResponseRequest;

                // if the responseRequest exists
                if (NullHelper.Exists(placeBetResponseRequest))
                {
                    // if this is a computer player
                    if (this.IsComputerPlayer)
                    {
                        // if the SendResponseCallBack exists
                        if (responseControl.HasSendResponseCallBack)
                        {
                            // To Do: Create a computer logic, this is just a stub for now
                            amountWagered = placeBetResponseRequest.TableMinimum * 7;

                            // If the PlayerControl object exists
                            if (this.HasPlayerControl)
                            {
                                // Show the amount the computer player bet
                                this.PlayerControl.ShowAmountWagered(amountWagered);
                            }

                            // Create the PlayerResponse
                            playerResponse = new PlayerResponse(ResponseTypeEnum.PlaceBet, amountWagered);

                            // Set the responseCallBack
                            responseControl.SendResponseCallBack(playerResponse);
                        }
                    }
                    else
                    {
                        // not a computer player, this is a human the dealer must interact with

                        // If the PlayerControl object exists
                        if ((this.HasPlayerControl) && (NullHelper.Exists(responseControl)))
                        {
                            // Create a new hand
                            hand.Player = this;

                            // Show the Chip Selector and the Amount Bet TextBox
                            this.PlayerControl.PromptForBet();

                            // Create the response and cast it as a PlaceBetResponse
                            PlaceBetResponseRequest request = PlayerResponseFactory.CreatePlayerResponseRequest(ResponseRequestTypeEnum.PlaceBet, responseControl, this.PlayerControl, houseRules) as PlaceBetResponseRequest;

                            // if the request exists
                            if (NullHelper.Exists(request))
                            {
                                // Setup the Response before showing
                                responseControl.ResponseRequest = request;

                                // Prompt the user for a response
                                playerResponse = request.Start(responseControl, this.PlayerControl);
                            }
                        }
                        else
                        {
                            // this must be sitting out
                            hand.SittingOut        = true;
                            hand.Player.SittingOut = true;
                        }
                    }
                }
                else
                {
                    // Without a ResponseRequest they are sitting out
                    this.SittingOut        = true;
                    hand.Player.SittingOut = true;
                }
            }

            // Change the status of this player if it changed
            this.SittingOut = hand.SittingOut;
        }
        /// <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);
        }
Ejemplo n.º 7
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);