/// <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; }
public Card(CardSuit suit, CardValue value, Image front, Image back) { Suit = suit; Value = value; FrontFace = front; BackFace = back; }
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; }
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)); }
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; }
// Обращение к карте по ее типу и масти public Card this[CardType type, CardSuit suit] { get { return list.Find(c => (c.Type == type) && (c.Suit == suit)); } }
// Метод создания бонуса - ему присваиваются тип, младшая карта, а также опционно для бонусов типа "последовательность" - масть 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; }
/// <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; }
public Order(OrderType Type, int Size, CardSuit Trump) { this.Type = Type; this.Size = Size; this.Trump = Trump; this.Team = BeloteTeam.TEAM_NONE; }
public static ICard Of(CardSuit cardSuit) { var jack = new Jack { _CardSuit = cardSuit }; return jack; }
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(); }
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); }
public static ICard Of(CardSuit cardSuit) { var king = new King { _CardSuit = cardSuit }; return king; }
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 ); }
/// <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; }
private Card CreateCard(int value, CardSuit suit, CardType type) { return new Card() { Value = value, Suit = suit, Type = type }; }
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"); }
public Bid(int tricks, CardSuit? trump) : this(BidType.Tricks) { if ((tricks < 6) || (tricks > 10)) throw new ArgumentOutOfRangeException("tricks"); mTricks = tricks; mTrump = trump; }
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); }
/// <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); }
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(); }
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)); }
/* 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 } }
// Метод создания бонуса - ему присваиваются тип, младшая карта, а также опционно для бонусов типа "последовательность" - масть 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 }
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); }
public int HowMuchTrumpsAreInPlay(CardSuit trumpSuit) { int count = 0; for (int j = 0; j < 6; j++) { if (usedCards[(int)trumpSuit, j] == false) { count++; } } return count; }
/// <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; }
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); }
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)); }
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; } }
public IncompatibleCardSuitException(CardSuit expectedSuit, CardSuit actualSuit) : base($"Card has incompatible suit. Expected: {expectedSuit}, actual: {actualSuit}") { ExpectedSuit = expectedSuit; ActualSuit = actualSuit; }
public override Card GetCard(CardFigure figure, CardSuit suit) { return(new GraphicCard(figure, suit)); }
public Card OfHearts() { this.Suit = CardSuit.Hearts; return(this); }
public Card(CardRank rank, CardSuit suit) { Rank = rank; Suit = suit; }
public Card(int id, CardSuit suit, int value) { Id = id; Suit = suit; Value = value; }
/// <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()); }
// Constructor public Card(CardKind kind, CardSuit suit) { mSuit = suit; mKind = kind; }
public Card OfSpades() { this.Suit = CardSuit.Spades; return(this); }
public Card(CardSuit suit, CardRank rank) { this.suit = suit; this.rank = rank; }
public Card(int value, CardSuit suite) : this(unchecked ((char)value), suite) { }
public Card(byte value, CardSuit suite) : this((char)value, suite) { }
public Card(CardValue value, CardSuit suit) { Value = value; Suit = suit; CardValue = (int)Value; }
public Card(CardRank rank, CardSuit suit) { this.Suit = suit; this.Rank = rank; this.Power = (int)suit + (int)rank; }
public Card(string rank, string suit) { this.rank = this.GetRankIfValid(rank); this.suit = this.GetSuitIfValid(suit); }
public Card OfDiamonds() { this.Suit = CardSuit.Diamonds; return(this); }
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); }
public Card(CardName name, CardSuit suit) { _name = name; _suit = suit; }
/// <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); }
public Card(CardNumber cardNumber, CardSuit cardSuit) { CardNumber = cardNumber; CardSuit = cardSuit; }
public Card(int value, int gameValue, CardSuit suit) { this.Value = value; this.Suit = suit; this.GameValue = gameValue; }
public Card(CardRank Rank, CardSuit Suit) { this._rank = Rank; this._suit = Suit; }
public Card OfClubs() { this.Suit = CardSuit.Clubs; return(this); }
public Card(int id, CardSuit suit) { _id = id; _suit = suit; }
public Card(CardType type, CardSuit suit) : this() { this.Type = type; this.Suit = suit; }
public Card(CardSuit aSuite, CardValue aValue) { suit = aSuite; value = aValue; }
public Card(CardSuit suit, CardType type) { this.Suit = suit; this.Type = type; }
private Card(CardSuit suit, CardValue value, bool isFaceDown) { Suit = suit; Value = value; IsFaceDown = isFaceDown; }
public Card(CardSuit suit, CardValue value) { Suit = suit; Value = value; }
public Card(CardFace face, CardSuit suit) { this.Face = face; this.Suit = suit; }
public Card(CardSuit s, int cardNum) { this.Suit = s; this.Number = cardNum; }