Пример #1
0
    public void OnTurnBegin()
    {
        view.OnTurnBegin();

        var LastTrick = TrickController.Instance.LastTrick;

        if (LastTrick != null)
        {
            analyzeCombination = LastTrick.Combination;
            analyzeFilter      = trick => trick > LastTrick.Key;
        }
        StartCoroutine("OnTurn");
        StartCoroutine("Analyze");
    }
Пример #2
0
    public void Announce(PokerHand.CombinationType comb)
    {
        if (comb == PokerHand.CombinationType.One)
        {
            return;
        }

        StopCoroutine("Announcement");
        announcer.color = Color.white;
        switch (comb)
        {
        case PokerHand.CombinationType.Pair:
            announcer.sprite = pair;
            break;

        case PokerHand.CombinationType.Triple:
            announcer.sprite = triple;
            break;

        case PokerHand.CombinationType.Straight:
            announcer.sprite = straight;
            break;

        case PokerHand.CombinationType.Flush:
            announcer.sprite = flush;
            break;

        case PokerHand.CombinationType.FullHouse:
            announcer.sprite = fullhouse;
            break;

        case PokerHand.CombinationType.StraightFlush:
            announcer.sprite = straightFlush;
            break;

        case PokerHand.CombinationType.RoyalFlush:
            announcer.sprite = royalFlush;
            break;

        case PokerHand.CombinationType.Dragon:
            announcer.sprite = dragon;
            break;

        default:
            announcer.sprite = null;
            break;
        }
        StartCoroutine("Announcement");
    }
Пример #3
0
    IEnumerator Analyze()
    {
        isAnalyzing = true;
        hands.Clear();
        List <PokerHand> result;

        // One analysis each frame
        switch (analyzeCombination)
        {
        case PokerHand.CombinationType.Invalid:
            goto case PokerHand.CombinationType.One;

        case PokerHand.CombinationType.One:
            hands.AddRange(One.Instance.LazyEvaluator(cards, false, analyzeFilter));

            if (analyzeCombination == PokerHand.CombinationType.Invalid)
            {
                goto case PokerHand.CombinationType.Pair;
            }
            break;

        case PokerHand.CombinationType.Pair:
            hands.AddRange(Pair.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter));

            if (analyzeCombination == PokerHand.CombinationType.Invalid)
            {
                goto case PokerHand.CombinationType.Triple;
            }
            break;

        case PokerHand.CombinationType.Triple:
            hands.AddRange(Triple.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter));

            if (analyzeCombination == PokerHand.CombinationType.Invalid)
            {
                goto case PokerHand.CombinationType.Straight;
            }
            break;

        case PokerHand.CombinationType.Straight:
            result = Straight.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.Straight = result[result.Count - 1].Cards;
            }
            if (!analyzeAllMatch && hands.Count > 0)
            {
                break;
            }
            yield return(null);

            goto case PokerHand.CombinationType.Flush;

        case PokerHand.CombinationType.Flush:
            result = Flush.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.Flush = result[result.Count - 1].Cards;
            }
            if (!analyzeAllMatch && hands.Count > 0)
            {
                break;
            }
            yield return(null);

            goto case PokerHand.CombinationType.FullHouse;

        case PokerHand.CombinationType.FullHouse:
            result = FullHouse.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.FullHouse = result[result.Count - 1].Cards;
            }
            if (!analyzeAllMatch && hands.Count > 0)
            {
                break;
            }
            yield return(null);

            goto case PokerHand.CombinationType.FourOfAKind;

        case PokerHand.CombinationType.FourOfAKind:
            result = FourOfAKind.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.FourOfAKind = result[result.Count - 1].Cards;
            }
            if (!analyzeAllMatch && hands.Count > 0)
            {
                break;
            }
            yield return(null);

            goto case PokerHand.CombinationType.StraightFlush;

        case PokerHand.CombinationType.StraightFlush:
            result = StraightFlush.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.StraightFlush = result[result.Count - 1].Cards;
            }
            if (!analyzeAllMatch && hands.Count > 0)
            {
                break;
            }
            yield return(null);

            goto case PokerHand.CombinationType.RoyalFlush;

        case PokerHand.CombinationType.RoyalFlush:
            result = RoyalFlush.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.RoyalFlush = result[result.Count - 1].Cards;
            }
            if (!analyzeAllMatch && hands.Count > 0)
            {
                break;
            }
            yield return(null);

            goto case PokerHand.CombinationType.Dragon;

        case PokerHand.CombinationType.Dragon:
            result = Dragon.Instance.LazyEvaluator(cards, analyzeAllMatch, analyzeFilter);
            hands.AddRange(result);
            if (result.Count > 0)
            {
                view.Dragon = result[result.Count - 1].Cards;
            }
            break;
        }

        if (hands.Count > 0)
        {
            yield return(null);

            var curr = hands[0];
            if (hands[hands.Count - 1].Combination == PokerHand.CombinationType.Dragon)
            {
                curr = hands[hands.Count - 1];
            }
            else
            {
                for (int i = 0; i < hands.Count; ++i)
                {
                    if (TrickController.Instance.IsFirstTurn &&
                        !(hands [i].Cards [0].Nominal == "3" && hands [i].Cards [0].suit == Card.Suit.Diamond))
                    {
                        continue;
                    }
                    if (curr.Combination != hands[i].Combination)
                    {
                        curr = hands[i];
                    }
                    if (curr.Combination >= PokerHand.CombinationType.Straight)
                    {
                        break;
                    }
                }
            }
            view.Hint = curr.Cards;
        }
        else
        {
            view.Hint = null;
        }

        isAnalyzing        = false;
        analyzeFilter      = null;
        analyzeCombination = PokerHand.CombinationType.Invalid;
    }
Пример #4
0
 public void OnSelectHint()
 {
     MarkAll(hint, true);
     lastMarkCombination = PokerHand.CombinationType.Invalid;
 }
Пример #5
0
 public void OnCardUnmarked(Card card)
 {
     markedCards.Remove(card);
     lastMarkCombination = PokerHand.CombinationType.Invalid;
 }
Пример #6
0
 public void OnSelectRoyalFlush()
 {
     MarkAll(royalFlush, lastMarkCombination != PokerHand.CombinationType.RoyalFlush);
     lastMarkCombination = PokerHand.CombinationType.RoyalFlush;
 }
Пример #7
0
 public void OnSelectDragon()
 {
     MarkAll(dragon, lastMarkCombination != PokerHand.CombinationType.Dragon);
     lastMarkCombination = PokerHand.CombinationType.Dragon;
 }
Пример #8
0
 public void OnSelectStraightFlush()
 {
     MarkAll(straightFlush, lastMarkCombination != PokerHand.CombinationType.StraightFlush);
     lastMarkCombination = PokerHand.CombinationType.StraightFlush;
 }
Пример #9
0
 public void OnSelectFourOfAKind()
 {
     MarkAll(fourOfAKind, lastMarkCombination != PokerHand.CombinationType.FourOfAKind);
     lastMarkCombination = PokerHand.CombinationType.FourOfAKind;
 }
Пример #10
0
 public void OnSelectFullHouse()
 {
     MarkAll(fullHouse, lastMarkCombination != PokerHand.CombinationType.FullHouse);
     lastMarkCombination = PokerHand.CombinationType.FullHouse;
 }
Пример #11
0
 public void OnSelectFlush()
 {
     MarkAll(flush, lastMarkCombination != PokerHand.CombinationType.Flush);
     lastMarkCombination = PokerHand.CombinationType.Flush;
 }
Пример #12
0
 // Helper events for interface
 public void OnSelectStraight()
 {
     MarkAll(straight, lastMarkCombination != PokerHand.CombinationType.Straight);
     lastMarkCombination = PokerHand.CombinationType.Straight;
 }