/// <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.º 2
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;
        }