当前位置: 首页>>代码示例>>C#>>正文


C# IHand.SetRank方法代码示例

本文整理汇总了C#中IHand.SetRank方法的典型用法代码示例。如果您正苦于以下问题:C# IHand.SetRank方法的具体用法?C# IHand.SetRank怎么用?C# IHand.SetRank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHand的用法示例。


在下文中一共展示了IHand.SetRank方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsHand

        public bool IsHand(IHand hand)
        {
            Suit? suit = null;
            Value? expectedCard = null;
            int cardsChecked = 0;

            foreach (var card in hand.GetCards().OrderBy(c => c.GetCardValue()))
            {
                if (!expectedCard.HasValue)
                {
                    expectedCard = card.GetCardValue();
                }
                if (cardsChecked == 4 && expectedCard == Value.Six && card.GetCardValue() == Value.Ace)
                {
                    hand.SetRank(Rank.StraightFlush);
                    return true;
                }

                if ((suit.HasValue && suit.Value != card.GetCardSuit())|| card.GetCardValue() != expectedCard)
                {

                    return false;
                }
                suit = card.GetCardSuit();
                expectedCard ++;
                cardsChecked++;
            }
            hand.SetRank(Rank.StraightFlush);
            return true;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:30,代码来源:StraightFlushAnalyser.cs

示例2: IsHand

        public bool IsHand(IHand hand)
        {
            var threeOfAKind = false;
            var pair = false;

            for (var i = Value.Two; i <= Value.Ace; i++)
            {
                IEnumerable<Card> cardsOfSameValue = hand.GetCards().Where(obj => obj.GetCardValue() == i);

                if (cardsOfSameValue.Count() > 2 && !threeOfAKind)
                {
                    threeOfAKind = true;

                }
                else if (cardsOfSameValue.Count() > 1 && !pair)
                {
                    pair = true;

                }
                if (threeOfAKind && pair)
                {
                    hand.SetRank(Rank.FullHouse);
                    return true;
                }
            }
            return false;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:27,代码来源:FullHouseAnalyser.cs

示例3: IsHand

        public bool IsHand(IHand hand)
        {
            for (var i = Value.Two; i <= Value.Ace; i ++)
            {
                var fourMatchCheck = hand.GetCards().Where(obj => obj.GetCardValue() == i);

                if (fourMatchCheck.Count() == 4)
                {
                    hand.SetRank(Rank.FourOfAKind);
                    return true;
                }
            }
            return false;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:14,代码来源:FourOfAKindAnalyser.cs

示例4: IsHand

        public bool IsHand(IHand hand)
        {
            for (var i = Value.Two; i <= Value.Ace; i++)
            {
                IEnumerable<Card> cardsOfSameValue = hand.GetCards().Where(obj => obj.GetCardValue() == i);

                if (cardsOfSameValue.Count() == 3)
                {
                    hand.SetRank(Rank.ThreeOfAKind);
                    return true;
                }
            }
            return false;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:14,代码来源:ThreeOfAKindAnalyser.cs

示例5: IsHand

 public bool IsHand(IHand hand)
 {
     Suit? suit = null;
     foreach (var card in hand.GetCards())
     {
         if (suit.HasValue && suit != card.GetCardSuit())
         {
             return false;
         }
         suit = card.GetCardSuit();
     }
     hand.SetRank(Rank.Flush);
     return true;
 }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:14,代码来源:FlushAnalyser.cs

示例6: IsStraight

        private bool IsStraight(IHand hand)
        {
            var sortedHand = hand.SortCards();
            var expectedNextCardValue = sortedHand[0].GetCardValue() + 1;

            for (var x = 1; x < sortedHand.Count; x++)
            {
                var currentCard = sortedHand[x];
                if (currentCard.GetCardValue() != expectedNextCardValue)
                {
                    return false;
                }
                expectedNextCardValue++;
            }
            hand.SetRank(Rank.Straight);
            return true;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:17,代码来源:StraightAnalyser.cs

示例7: IsHand

        public bool IsHand(IHand hand)
        {
            Suit? suit = null;
            var expectedCard = Value.Ten;
            foreach (var card in hand.GetCards().OrderBy(c => c.GetCardValue()))
            {
                if ((suit.HasValue && suit.Value != card.GetCardSuit()) || (card.GetCardValue() != expectedCard))
                {
                    return false;
                }
                expectedCard++;
                suit = card.GetCardSuit();
            }
            hand.SetRank(Rank.RoyalFlush);

            return true;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:17,代码来源:RoyalFlushHandAnalyser.cs

示例8: IsHand

        public bool IsHand(IHand hand)
        {
            var numberOfPairs = 0;
            for (var i = Value.Two; i <= Value.Ace; i++)
            {
                var cardsOfSameValue = hand.GetCards().Where(obj => obj.GetCardValue() == i);

                if (cardsOfSameValue.Count() == 2)
                {
                    numberOfPairs++;
                }

            }
            if (numberOfPairs == 1)
            {
                hand.SetRank(Rank.Pair);
                return true;
            }
            return false;
        }
开发者ID:rHarris213,项目名称:PokerGame,代码行数:20,代码来源:OnePairAnalyser.cs


注:本文中的IHand.SetRank方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。