コード例 #1
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);
                }
            }
        }
コード例 #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;
        }