Ejemplo n.º 1
0
 public void GiveCard(PlayingCard card)
 {
     Log.info(card.ToChatString() + " given.");
     cards.Add(card);
 }
Ejemplo n.º 2
0
 public CardCollection(PlayingCard[] playingCard = null)
 {
     this.cards = new List<PlayingCard>(playingCard ?? new PlayingCard[] { });
 }
Ejemplo n.º 3
0
        static void CalcHandStats(CardCollection playerCards, out bool isFlush, out PlayingCard.Value? firstPairValue, out PlayingCard.Value? secondPairValue, out uint firstPairCardCount, out uint secondPairCardCount, out bool isStraight)
        {
            PlayingCard.Value? lastCardValue = null;
            firstPairValue = null;
            secondPairValue = null;
            firstPairCardCount = 0;
            secondPairCardCount = 0;
            isStraight = true;
            isFlush = CheckForFlush(playerCards);

            foreach(var card in playerCards.cards) {
                if(lastCardValue != null) {
                    if(card.value != lastCardValue.Value + 1) {
                        isStraight = false;
                    }

                    if(card.value == lastCardValue.Value) {
                        if(firstPairValue == null) {
                            firstPairValue = card.value;
                            firstPairCardCount = 2;
                        } else if(card.value == firstPairValue) {
                            firstPairCardCount++;
                        } else if(card.value == secondPairValue) {
                            secondPairCardCount++;
                        } else {
                            Debug.Assert(secondPairValue == null);
                            secondPairValue = card.value;
                            secondPairCardCount = 2;
                        }
                    }
                }
                lastCardValue = card.value;
            }
        }
Ejemplo n.º 4
0
 private static ulong GetValue(PlayingCard.Value value1, PlayingCard.Value value2, PlayingCard.Value value3, PlayingCard.Value value4, PlayingCard.Value value5)
 {
     return (ulong)value1 * 13 ^ 4 + (ulong)value2 * 13 ^ 3 + (ulong)value3 * 13 ^ 2 + (ulong)value4 * 13 ^ 1 + (ulong)value5;
 }
 static ulong GetValue(PlayingCard.Value value1, PlayingCard.Value value2, PlayingCard.Value value3, PlayingCard.Value value4, PlayingCard.Value value5)
 {
     return (ulong)((ulong)value1 * Math.Pow(13,4) + (ulong)value2 * Math.Pow(13, 3) + (ulong)value3 * Math.Pow(13,2) + (ulong)value4 * 13 + (ulong)value5);
 }