Exemple #1
0
    /// <summary>
    /// Utility function used to populate the info text correctly based off potential win or win type.
    /// </summary>
    /// <returns></returns>
    private void UpdateInfoTextBasedOnHandResults()
    {
        DeckConstants.PokerHandType type = ActiveStrategy.DeterminePokerHandType(hand);
        string infoText = ActiveStrategy.GetInfoTextStringForHandType(type);

        Messenger.Broadcast <string>(GameEvents.Award.UpdateInfoText, infoText);
    }
Exemple #2
0
    /// <summary>
    /// Utility function used to return a string to display in info text.
    /// </summary>
    /// <param name="handType"></param>
    /// <returns></returns>
    public string GetInfoTextStringForHandType(DeckConstants.PokerHandType handType)
    {
        switch (handType)
        {
        case DeckConstants.PokerHandType.RoyalFlush: return(RoyalFlushWinViewName);

        case DeckConstants.PokerHandType.StraightFlush: return(StraightFlushWinViewName);

        case DeckConstants.PokerHandType.FourOfAKind: return(FourOfAKindWinViewName);

        case DeckConstants.PokerHandType.FullHouse: return(FullHouseWinViewName);

        case DeckConstants.PokerHandType.Flush: return(FlushWinViewName);

        case DeckConstants.PokerHandType.Straight: return(StraightWinViewName);

        case DeckConstants.PokerHandType.ThreeOfAKind: return(ThreeOfAKindWinViewName);

        case DeckConstants.PokerHandType.TwoPair: return(TwoPairWinViewName);

        case DeckConstants.PokerHandType.JacksOrBetter: return(JacksOrBetterWinViewName);

        default: break;
        }

        return(string.Empty);
    }
Exemple #3
0
    /// <summary>
    /// Overloading the regular DeterminePokerHandType function to check for JacksOrWild specific conditions.
    /// </summary>
    /// <param name="pokerHand"></param>
    /// <returns></returns>
    public DeckConstants.PokerHandType DeterminePokerHandType(List <DeckConstants.StandardCard> pokerHand)
    {
        // Copy the hand as to not to destroy the order of the original hand when we sort it.
        List <DeckConstants.StandardCard> handCopy = CopyHand(pokerHand);

        // NOTE: It would be possible to save a bit of performance by doing these calculations individually and returning immediately if they succeed or fail,
        //       however this implementation allows for the ability to over ride the standard poker return values and do additional evaluations to check for
        //       strategy specific information such as JacksOrBetter.
        StandardCardPokerDataContext jacksOrBetterDataContext = new StandardCardPokerDataContext(StandardCardPokerUtils.AreAllCardsInHandTheSameSuit(handCopy),
                                                                                                 StandardCardPokerUtils.IsStraight(handCopy),
                                                                                                 StandardCardPokerUtils.AreAllTenOrAbove(handCopy),
                                                                                                 StandardCardPokerUtils.FindSetsOfCardsWithSameValue(handCopy));

        DeckConstants.PokerHandType handType = StandardCardPokerUtils.DeterminePokerHandType(jacksOrBetterDataContext, handCopy);

        if (handType == DeckConstants.PokerHandType.Pair)
        {
            bool isJackOrGreater = (jacksOrBetterDataContext.SameCardSets.Count > 0 &&
                                    (int)handCopy[jacksOrBetterDataContext.SameCardSets[0].IndexList[0]].value >= (int)DeckConstants.CardValue.Jack);
            if (isJackOrGreater)
            {
                return(DeckConstants.PokerHandType.JacksOrBetter);
            }
        }

        return(handType);
    }
Exemple #4
0
    /// <summary>
    /// The main play poker coroutine.
    /// </summary>
    /// <returns></returns>
    private IEnumerator PlayPokerCoroutine()
    {
        while (currentRound < ActiveStrategy.GetHandsPerRound())
        {
            ActiveStrategy.DealCards(hand, cardsToHold, deckStack);

            // Reveal the cards.
            yield return(RevealCardsCoroutine());

            // Display info text if this is not the last hand of the game.
            UpdateInfoTextBasedOnHandResults();

            yield return(WaitForPlayerDrawConfirmationCoroutine());

            currentRound++;
            yield return(null);
        }

        // Delay before all 5 cards finish their reveal.
        yield return(waitForDelay);

        DeckConstants.PokerHandType type = ActiveStrategy.DeterminePokerHandType(hand);
        string infoText = ActiveStrategy.GetInfoTextStringForHandType(type);

        if (infoText == string.Empty)
        {
            infoText = GAME_OVER_TEXT;
        }

        Messenger.Broadcast <string>(GameEvents.Award.UpdateInfoText, infoText);
        Messenger.Broadcast <StandardCardDeck.DeckConstants.PokerHandType>(GameEvents.Award.ReportWin, type);

        // Reset the hold buttons for next wager.
        for (int i = 0; i < cardsToHold.Count; ++i)
        {
            cardsToHold[i] = false;
        }

        IsPokerGameInPlay = false;
        yield return(null);
    }