HoldemHand.Hand.DescriptionFromMask C# (CSharp) Method

DescriptionFromMask() public static method

Evaluates a hand and returns a descriptive string.
public static DescriptionFromMask ( ulong cards ) : string
cards ulong Card mask
return string
        public static string DescriptionFromMask(ulong cards)
        {
            int numberOfCards = BitCount(cards);

            #if DEBUG
            // This functions supports 1-7 cards
            if (numberOfCards < 1 || numberOfCards > 7)
                throw new ArgumentOutOfRangeException("numberOfCards");
            #endif
            // Seperate out by suit
            uint sc = (uint)((cards >> (CLUB_OFFSET)) & 0x1fffUL);
            uint sd = (uint)((cards >> (DIAMOND_OFFSET)) & 0x1fffUL);
            uint sh = (uint)((cards >> (HEART_OFFSET)) & 0x1fffUL);
            uint ss = (uint)((cards >> (SPADE_OFFSET)) & 0x1fffUL);

            uint handvalue = Evaluate(cards, numberOfCards);

            switch ((HandTypes)HandType(handvalue))
            {
                case HandTypes.HighCard:
                case HandTypes.Pair:
                case HandTypes.TwoPair:
                case HandTypes.Trips:
                case HandTypes.Straight:
                case HandTypes.FullHouse:
                case HandTypes.FourOfAKind:
                    return DescriptionFromHandValueInternal(handvalue);
                case HandTypes.Flush:
                    if (nBitsTable[ss] >= 5)
                    {
                        return "Flush (Spades) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    else if (nBitsTable[sc] >= 5)
                    {
                        return "Flush (Clubs) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    else if (nBitsTable[sd] >= 5)
                    {
                        return "Flush (Diamonds) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    else if (nBitsTable[sh] >= 5)
                    {
                        return "Flush (Hearts) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    break;
                case HandTypes.StraightFlush:
                    if (nBitsTable[ss] >= 5)
                    {
                        return "Straight Flush (Spades) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    else if (nBitsTable[sc] >= 5)
                    {
                        return "Straight (Clubs) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    else if (nBitsTable[sd] >= 5)
                    {
                        return "Straight (Diamonds) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    else if (nBitsTable[sh] >= 5)
                    {
                        return "Straight  (Hearts) with " + ranktbl[TopCard(handvalue)] + " high";
                    }
                    break;
            }
            Debug.Assert(false); // Should never get here
            return "";
        }