コード例 #1
0
ファイル: Card.cs プロジェクト: SpectralCoding/blackjack
 /// <summary>
 /// Initializes a new instance of the Card class.
 /// </summary>
 /// <param name="CardType">Type of card to create.</param>
 /// <param name="CardSuit">Suit of card to create.</param>
 public Card(CardType CardType, CardSuit CardSuit)
 {
     m_Suit = CardSuit;
     m_Type = CardType;
     m_InternalValue = (int)CardType;
     m_IsHigh = true;
 }
コード例 #2
0
ファイル: Card.cs プロジェクト: RedHobbit/ClockPatience
 public Card(CardSuit suit, CardValue value, Image front, Image back)
 {
     Suit = suit;
     Value = value;
     FrontFace = front;
     BackFace = back;
 }
コード例 #3
0
        public Card GetCardWithSuitThatEnemyDoesNotHave(bool enemyHasATrumpCard, CardSuit trumpSuit, ICollection<Card> playerCards)
        {
            if (!enemyHasATrumpCard)
            {
                // In case the enemy does not have any trump cards and Stalker has a trump, he should throw a trump.
                var myTrumpCards = playerCards.Where(c => c.Suit == trumpSuit).ToList();
                if (myTrumpCards.Count() > 0)
                {
                    return myTrumpCards.OrderBy(c => c.GetValue()).LastOrDefault();
                }
            }

            var orderedCards = playerCards.OrderBy(c => c.GetValue());
            foreach (var card in orderedCards)
            {
                if (this.cardHolder.EnemyCards.All(c => c.Suit != card.Suit))
                {
                    if (enemyHasATrumpCard)
                    {
                        return playerCards.Where(c => c.Suit == card.Suit).OrderBy(c => c.GetValue()).FirstOrDefault();
                    }

                    return playerCards.Where(c => c.Suit == card.Suit).OrderByDescending(c => c.GetValue()).FirstOrDefault();
                }
            }

            return null;
        }
コード例 #4
0
ファイル: CardTests.cs プロジェクト: vermeeca/Katas
        public void CardValueTest(CardValue value1, CardSuit suit1, CardValue value2, CardSuit suit2, int expected)
        {
            Card card1 = new Card(value1, suit1);
            Card card2 = new Card(value2, suit2);

            Assert.AreEqual(expected, card1.CompareTo(card2));
        }
コード例 #5
0
        public ICollection<Card> GetOpponentCards(ICollection<Card> myCards, ICollection<Card> playedCards, Card activeTrumpCard, CardSuit suit)
        {
            var playerCards = new CardCollection
                                  {
                                      new Card(suit, CardType.Nine),
                                      new Card(suit, CardType.Jack),
                                      new Card(suit, CardType.Queen),
                                      new Card(suit, CardType.King),
                                      new Card(suit, CardType.Ten),
                                      new Card(suit, CardType.Ace),
                                  };

            foreach (var card in myCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            foreach (var card in playedCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            if (activeTrumpCard != null)
            {
                playerCards.Remove(activeTrumpCard);
            }

            return playerCards;
        }
コード例 #6
0
ファイル: CardList.cs プロジェクト: TawaSystems/belotetest
 // Обращение к карте по ее типу и масти
 public Card this[CardType type, CardSuit suit]
 {
     get
     {
         return list.Find(c => (c.Type == type) && (c.Suit == suit));
     }
 }
コード例 #7
0
ファイル: Bonus.cs プロジェクト: TawaSystems/belotetest
 // Метод создания бонуса - ему присваиваются тип, младшая карта, а также опционно для бонусов типа "последовательность" - масть
 public Bonus(BonusType Type, CardType HighCard, bool IsTrump, CardSuit Suit = CardSuit.C_NONE)
 {
     this.Type = Type;
     this.HighCard = HighCard;
     this.Suit = Suit;
     this.IsTrump = IsTrump;
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Card"/> class.
 /// </summary>
 /// <param name="cardIndex">Index of the card.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="sequenceNumber">The sequence number.</param>
 public Card(int cardIndex, CardMode mode, int sequenceNumber)
 {
     this._suit = GetSuitFromCardIndex(cardIndex, mode);
     this._rank = GetRankFromIndex(cardIndex, mode);
     this._sequence = sequenceNumber;
     this._cardIndex = cardIndex;
 }
コード例 #9
0
ファイル: Order.cs プロジェクト: TawaSystems/belotetest
 public Order(OrderType Type, int Size, CardSuit Trump)
 {
     this.Type = Type;
     this.Size = Size;
     this.Trump = Trump;
     this.Team = BeloteTeam.TEAM_NONE;
 }
コード例 #10
0
ファイル: Jack.cs プロジェクト: tekavec/WarGameKata
 public static ICard Of(CardSuit cardSuit)
 {
     var jack = new Jack
     {
         _CardSuit = cardSuit
     };
     return jack;
 }
コード例 #11
0
ファイル: Card.cs プロジェクト: MiBuena/HighQualityProject
 public Card(CardSuit suit, CardRank rank, Image frontImage) : this(suit, rank)
 {
     this.FrontImage = frontImage;
     //Can we make it to private readonly or const?
     this.BackCardPath = "..\\..\\Resources\\Cards\\Back.png";
     this.BackImage = Image.FromFile(BackCardPath);
     this.CardPictureBox = new PictureBox();
 }
コード例 #12
0
        private double GetFailureProbabilityForSuit(int cards, int discards, CardSuit suit)
        {
            int cardSet = BitwiseCardHelper.GetCardSet(cards, suit);
            int discardsCount = BitwiseCardHelper.GetSuitCount(discards, suit);
            int otherSuitsDistribution = CardSuitDistribution.GetDistribution(cards, discards, suit);

            return MisereProbabilities.GetFailureProbability(cardSet, discardsCount, otherSuitsDistribution, IsFirstHand);
        }
コード例 #13
0
ファイル: King.cs プロジェクト: tekavec/WarGameKata
 public static ICard Of(CardSuit cardSuit)
 {
     var king = new King
     {
         _CardSuit = cardSuit
     };
     return king;
 }
コード例 #14
0
ファイル: Card.cs プロジェクト: arudnitsky/Solitaire
 public Card( int rank, CardSuit suit, CardOrientation orientation = CardOrientation.FaceDown )
 {
     if ( rank < (int)CardRank.Ace || rank > (int)CardRank.King )
      {
     throw new ArgumentException( "Invalid card rank" );
      }
      InitCard( (CardRank) rank, suit, orientation );
 }
コード例 #15
0
ファイル: GameRule.cs プロジェクト: nishesj/callbreak
 /// <summary>
 /// checks the hand if it has the passed suit or not
 /// </summary>
 /// <param name="suit">Suit of the card to check.</param>
 /// <param name="hand">Hand of the player to check in.</param>
 /// <returns></returns>
 public static bool hasSuit(CardSuit suit, Hand hand)
 {
     foreach (SpadesCard card in hand.CardPile)
     {
         if (Card.SuitFromCardIndex(card.CardIndex) == suit) return true;
     }
     return false;
 }
コード例 #16
0
ファイル: Deck.cs プロジェクト: Adamsons/21
 private Card CreateCard(int value, CardSuit suit, CardType type)
 {
     return new Card()
     {
         Value = value,
         Suit = suit,
         Type = type
     };
 }
コード例 #17
0
        public void ChangeTrumpCardTest(CardSuit suit, CardType type)
        {
            var newCard = new Card(suit, type);
            var deck = new Deck();

            deck.ChangeTrumpCard(newCard);

            Assert.AreNotEqual(0, deck.CardsLeft, "Change card doesn't work");
        }
コード例 #18
0
ファイル: Bid.cs プロジェクト: DVorobyev/Preference
        public Bid(int tricks, CardSuit? trump)
            : this(BidType.Tricks)
        {
            if ((tricks < 6) || (tricks > 10))
                throw new ArgumentOutOfRangeException("tricks");

            mTricks = tricks;
            mTrump = trump;
        }
コード例 #19
0
ファイル: Card.cs プロジェクト: sciaopin/bang-sharp
 protected Card(Game game, int id, CardType type, CardSuit suit, CardRank rank)
 {
     this.game = game;
     this.id = id;
     this.type = type;
     this.suit = suit;
     this.rank = rank;
     color = GetColor(type);
     empty = new EmptyCard(this);
 }
コード例 #20
0
ファイル: SpadesCard.cs プロジェクト: nishesj/callbreak
 /// <summary>
 /// constructor of spades card
 /// </summary>
 /// <param name="i">Card Index</param>
 public SpadesCard(int i)
     : base()
 {
     if (i < 0 || i > 52)
     {
         throw new ApplicationException("Wrong value for card initilization.");
     }
        _cardindex = i;
        Suit = Card.SuitFromCardIndex(i);
        Rank = Card.RankFromCardIndex(i);
 }
コード例 #21
0
 public PlayingCardWidget(int id, CardType type, CardRank rank, CardSuit suit)
 {
     layout = new Pango.Layout(Gdk.PangoHelper.ContextGet());
     layout.FontDescription = Pango.FontDescription.FromString("Angleterre Book, Librarian bold 32");
     this.id = id;
     this.type = type;
     this.rank = rank;
     this.suit = suit;
     Card = CardManager.GetCard(type);
     UpdateMarkup();
 }
コード例 #22
0
 public void EqualsShouldWorkCorrectly(
     bool expectedValue,
     CardSuit firstCardSuit,
     CardType firstCardType,
     CardSuit secondCardSuit,
     CardType secondCardType)
 {
     var firstCard = new Card(firstCardSuit, firstCardType);
     var secondCard = new Card(secondCardSuit, secondCardType);
     Assert.AreEqual(expectedValue, firstCard.Equals(secondCard));
     Assert.AreEqual(expectedValue, secondCard.Equals(firstCard));
 }
コード例 #23
0
ファイル: Card.cs プロジェクト: JGEsteves89/DaCMain
 /* Helper method to convert CardSuit enum value into a char */
 public static Char CardSuitToChar(CardSuit s)
 {
     switch (s)
     {
         case CardSuit.Spades: return 'S';
         case CardSuit.Clubs: return 'C';
         case CardSuit.Diamonds: return 'D';
         case CardSuit.Hearts: return 'H';
         default:
             Trace.Assert(false, "Invalid cardsuit detected during conversion to char: " + s);
             return 'H'; // Never to be executed
     }
 }
コード例 #24
0
ファイル: Bonus.cs プロジェクト: TawaSystems/belotetest
 // Метод создания бонуса - ему присваиваются тип, младшая карта, а также опционно для бонусов типа "последовательность" - масть
 public Bonus(BonusType Type, CardType HighCard, bool IsTrump, CardSuit Suit = CardSuit.C_NONE)
 {
     Cards = new BaseCardList();
     this.Type = Type;
     this.HighCard = HighCard;
     this.Suit = Suit;
     this.IsTrump = IsTrump;
     Cost = CalculateCost();
     #if DEBUG
     Debug.WriteLine("{0} Создан бонус: Тип - {1}, Старшая карта - {2}, Масть - {3}, Козырь - {4}, Стоимость - {5}",
         DateTime.Now.ToString(), Type, HighCard, Suit, IsTrump, Cost);
     #endif
 }
コード例 #25
0
ファイル: DeckTests.cs プロジェクト: studware/Ange-Git
 public void TestChangeTrumpCardShouldProperlyUpdateBothTrumpCardAndDeckTopCard(CardSuit suit, CardType type)
 {
     Deck deck = new Deck();
     Card newTrumpCard = new Card(suit, type);
     deck.ChangeTrumpCard(newTrumpCard);
     int cardsCount = deck.CardsLeft;
     Card topCard = deck.GetNextCard();
     for (int i = 1; i < cardsCount; i++)
     {
         topCard = deck.GetNextCard();
     }
     Assert.AreEqual(topCard, newTrumpCard);
 }
コード例 #26
0
        public int HowMuchTrumpsAreInPlay(CardSuit trumpSuit)
        {
            int count = 0;

            for (int j = 0; j < 6; j++)
            {
                if (usedCards[(int)trumpSuit, j] == false)
                {
                    count++;
                }
            }

            return count;
        }
コード例 #27
0
ファイル: Deck.cs プロジェクト: SomeSideProjects/old.FreeCell
        /// <summary>
        /// Generates all 13 cards of the same suit
        /// </summary>
        /// <param name="suit"></param>
        /// <returns></returns>
        protected Deck SingleSuit(CardSuit suit)
        {
            Deck ToReturn = new Deck();
            Card ToAdd;

            for(int i = 0; i < 13; i++)
            {
                ToAdd = new Card(suit, (CardValue)i);
                ToReturn.Add(ToAdd);
                if (i == 0) ToReturn.FirstCard = ToAdd;
                if (i == 13) ToReturn.LastCard = ToAdd;
            }

            return ToReturn;
        }
コード例 #28
0
ファイル: CardUtils.cs プロジェクト: pJqEM5Kj/stuff
        public static string ConvertToString(CardSuit cardSuit)
        {
            switch (cardSuit)
            {
                case CardSuit.Spades:
                    return "s";
                case CardSuit.Hearts:
                    return "h";
                case CardSuit.Diamonds:
                    return "d";
                case CardSuit.Clubs:
                    return "c";
            }

            throw Utility.GetUnknownEnumValueException(cardSuit);
        }
コード例 #29
0
        public void IsTwoPairTestValid(CardFace face1, CardSuit suit1, CardFace face2, CardSuit suit2, CardFace face3, CardSuit suit3, CardFace face4, CardSuit suit4, CardFace face5, CardSuit suit5)
        {
            // Didn't found better way to implement many cards with NUnit
            var cards = new List<ICard>()
            {
                new Card(face1, suit1),
                new Card(face2, suit2),
                new Card(face3, suit3),
                new Card(face4, suit4),
                new Card(face5, suit5),
            };

            var hand = new Hand(cards);

            Assert.IsTrue(this.checker.IsOnePair(hand));
        }
コード例 #30
0
ファイル: Card.cs プロジェクト: hristian-dimov/TelerikAcademy
 private string CheckCardSuite(CardSuit cardSuit)
 {
     switch (cardSuit)
     {
         case CardSuit.Clubs:
             return "♣"; break;
         case CardSuit.Diamonds:
             return "♦"; break;
         case CardSuit.Hearts:
             return "♥"; break;
         case CardSuit.Spades:
             return "♠"; break;
         default:
             throw new ArgumentException("Invalid Card suite!"); break;
     }
 }
コード例 #31
0
 public IncompatibleCardSuitException(CardSuit expectedSuit, CardSuit actualSuit)
     : base($"Card has incompatible suit. Expected: {expectedSuit}, actual: {actualSuit}")
 {
     ExpectedSuit = expectedSuit;
     ActualSuit   = actualSuit;
 }
コード例 #32
0
ファイル: GraphicCardSet.cs プロジェクト: gitpten/CardGameWF
 public override Card GetCard(CardFigure figure, CardSuit suit)
 {
     return(new GraphicCard(figure, suit));
 }
コード例 #33
0
 public Card OfHearts()
 {
     this.Suit = CardSuit.Hearts;
     return(this);
 }
コード例 #34
0
ファイル: Card.cs プロジェクト: svenM/BlackJackChallenge
 public Card(CardRank rank, CardSuit suit)
 {
     Rank = rank;
     Suit = suit;
 }
コード例 #35
0
 public Card(int id, CardSuit suit, int value)
 {
     Id    = id;
     Suit  = suit;
     Value = value;
 }
コード例 #36
0
ファイル: RedSuit.cs プロジェクト: FireEmblem16/Mahjong
 /// <summary>
 /// Returns true if this suit is the same suit as the provided suit.
 /// </summary>
 /// <param name="s">The suit to compare with.</param>
 /// <returns>Returns true if the two suits are the same and false otherwise.</returns>
 public bool Equals(CardSuit s)
 {
     return(ToString() == s.ToString());
 }
コード例 #37
0
ファイル: Card.cs プロジェクト: akariin/CECS475
 // Constructor
 public Card(CardKind kind, CardSuit suit)
 {
     mSuit = suit;
     mKind = kind;
 }
コード例 #38
0
 public Card OfSpades()
 {
     this.Suit = CardSuit.Spades;
     return(this);
 }
コード例 #39
0
ファイル: Card.cs プロジェクト: JNKielmann/Luegen
 public Card(CardSuit suit, CardRank rank)
 {
     this.suit = suit;
     this.rank = rank;
 }
コード例 #40
0
 public Card(int value, CardSuit suite) : this(unchecked ((char)value), suite)
 {
 }
コード例 #41
0
 public Card(byte value, CardSuit suite) : this((char)value, suite)
 {
 }
コード例 #42
0
 public Card(CardValue value, CardSuit suit)
 {
     Value     = value;
     Suit      = suit;
     CardValue = (int)Value;
 }
コード例 #43
0
ファイル: Card.cs プロジェクト: ValentinnDimitroff/SoftUni
 public Card(CardRank rank, CardSuit suit)
 {
     this.Suit  = suit;
     this.Rank  = rank;
     this.Power = (int)suit + (int)rank;
 }
コード例 #44
0
ファイル: Card.cs プロジェクト: gaydov/Softuni-OOP-Advanced
 public Card(string rank, string suit)
 {
     this.rank = this.GetRankIfValid(rank);
     this.suit = this.GetSuitIfValid(suit);
 }
コード例 #45
0
 public Card OfDiamonds()
 {
     this.Suit = CardSuit.Diamonds;
     return(this);
 }
コード例 #46
0
        public HandType GetHandType()
        {
            if (Cards.Count < MaxCardsInHand)
            {
                return(HandType.Undefined);
            }
            if (_handType == HandType.Undefined)
            {
                int[] values = new int[_handHistogram.Values.Count];
                _handHistogram.Values.CopyTo(values, 0);
                Array.Sort(values);
                int maxRankCount = values[values.Length - 1];

                // Check if the hand is quads or boat
                if (_handHistogram.Count < 3)
                {
                    if (maxRankCount == 4)
                    {
                        return(HandType.FourOfAKind);
                    }
                    else
                    {
                        return(HandType.FullHouse);
                    }
                }
                else if (_handHistogram.Count == 3)
                {
                    if (maxRankCount == 3)
                    {
                        return(HandType.ThreeOfAKind);
                    }
                    else
                    {
                        return(HandType.TwoPair);
                    }
                }
                else if (_handHistogram.Count == 4)
                {
                    return(HandType.OnePair);
                }

                bool isFlush    = false;
                bool isStraight = false;
                // Check if the hand is flush
                CardSuit firstCardSuit = Cards[0].Suit;
                int      sameSuitCount = 0;
                foreach (Card card in Cards)
                {
                    if (card.Suit == firstCardSuit)
                    {
                        sameSuitCount++;
                    }
                }
                isFlush = (sameSuitCount == Cards.Count);

                Card[] cardsArray = new Card[Cards.Count];
                Cards.CopyTo(cardsArray, 0);
                Array.Sort(cardsArray);

                // Check if the hand is straight
                CardValue topCardRank          = cardsArray[MaxCardsInHand - 1].Value;
                CardValue nextToTheTopCardRank = cardsArray[MaxCardsInHand - 2].Value;
                CardValue bottomCardRank       = cardsArray[0].Value;
                if ((nextToTheTopCardRank == CardValue.Five &&
                     topCardRank == CardValue.Ace &&
                     nextToTheTopCardRank - bottomCardRank == 3) ||
                    (topCardRank - bottomCardRank == 4))
                {
                    isStraight = true;
                }
                if (isStraight && isFlush)
                {
                    return(HandType.StraightFlush);
                }
                else if (isStraight)
                {
                    return(HandType.Straight);
                }
                else if (isFlush)
                {
                    return(HandType.Flush);
                }
                _handType = HandType.HighCard;
            }
            return(_handType);
        }
コード例 #47
0
 public Card(CardName name, CardSuit suit)
 {
     _name = name;
     _suit = suit;
 }
コード例 #48
0
        /// <summary>
        /// Funkcja liczaca ktory z graczy wygral lewe.
        /// </summary>
        /// <returns>Numer gracza ktory wygral lewe.</returns>
        static public int TrickWinner(Card first, Card second, Card third, Card fourth, CardSuit trump, int wistNumber)
        {
            Card        winnerCard;
            int         winnerIndex = 1;
            List <Card> trickCards  = new List <Card>();

            // 1 2 3 4 1 2 3 <- dzieki temu nie musze sie bawic w sprawdzanie
            trickCards.Add(first); trickCards.Add(second); trickCards.Add(third); trickCards.Add(fourth); trickCards.Add(first); trickCards.Add(second); trickCards.Add(third);

            winnerIndex = CompareCards(trickCards[wistNumber - 1], trickCards[wistNumber], trump, out winnerCard) ? wistNumber : wistNumber + 1;
            winnerIndex = CompareCards(winnerCard, trickCards[wistNumber + 1], trump, out winnerCard) ? winnerIndex : wistNumber + 2;
            winnerIndex = CompareCards(winnerCard, trickCards[wistNumber + 2], trump, out winnerCard) ? winnerIndex : wistNumber + 3;

            //zrob modulo zeby wynik byl w przedziale [1,4]
            return((winnerIndex - 1) % 4 + 1);
        }
コード例 #49
0
ファイル: Card.cs プロジェクト: mburakeker/blackjack
 public Card(CardNumber cardNumber, CardSuit cardSuit)
 {
     CardNumber = cardNumber;
     CardSuit   = cardSuit;
 }
コード例 #50
0
ファイル: Card.cs プロジェクト: manofmistery/bigtwo
 public Card(int value, int gameValue, CardSuit suit)
 {
     this.Value     = value;
     this.Suit      = suit;
     this.GameValue = gameValue;
 }
コード例 #51
0
ファイル: Card.cs プロジェクト: ktwilson/PokerTest
 public Card(CardRank Rank, CardSuit Suit)
 {
     this._rank = Rank;
     this._suit = Suit;
 }
コード例 #52
0
 public Card OfClubs()
 {
     this.Suit = CardSuit.Clubs;
     return(this);
 }
コード例 #53
0
 public Card(int id, CardSuit suit)
 {
     _id   = id;
     _suit = suit;
 }
コード例 #54
0
 public Card(CardType type, CardSuit suit)
     : this()
 {
     this.Type = type;
     this.Suit = suit;
 }
コード例 #55
0
ファイル: Card.cs プロジェクト: obstrel/Kozel
 public Card(CardSuit aSuite, CardValue aValue)
 {
     suit  = aSuite;
     value = aValue;
 }
コード例 #56
0
ファイル: Card.cs プロジェクト: DobKostadinov/TelerikAcademy
 public Card(CardSuit suit, CardType type)
 {
     this.Suit = suit;
     this.Type = type;
 }
コード例 #57
0
ファイル: Card.cs プロジェクト: aNNiMON/Rouge-et-Noir
 private Card(CardSuit suit, CardValue value, bool isFaceDown)
 {
     Suit       = suit;
     Value      = value;
     IsFaceDown = isFaceDown;
 }
コード例 #58
0
 public Card(CardSuit suit, CardValue value)
 {
     Suit  = suit;
     Value = value;
 }
コード例 #59
0
ファイル: Card.cs プロジェクト: RashaHussein/Telerik-Academy
 public Card(CardFace face, CardSuit suit)
 {
     this.Face = face;
     this.Suit = suit;
 }
コード例 #60
0
 public Card(CardSuit s, int cardNum)
 {
     this.Suit   = s;
     this.Number = cardNum;
 }