public void SetSuitUnless(SuitEnum suit, T set, Func <T, bool> unless) { switch (suit) { case SuitEnum.Heart: if (!unless.Invoke(HeartStatus)) { HeartStatus = set; } break; case SuitEnum.Spade: if (!unless.Invoke(SpadeStatus)) { SpadeStatus = set; } break; case SuitEnum.Diamond: if (!unless.Invoke(DiamondStatus)) { DiamondStatus = set; } break; case SuitEnum.Club: if (!unless.Invoke(ClubStatus)) { ClubStatus = set; } break; } }
public SuitedStatus <BoardRangeGridStatusEnum> TestSuitedGrid(RangeGrid grid) { if (grid.Category != GridCategoryEnum.Suited) { throw new InvalidOperationException($"{grid.Category}"); } var result = new SuitedStatus <BoardRangeGridStatusEnum>(); var suits = new SuitEnum[] { SuitEnum.Heart, SuitEnum.Spade, SuitEnum.Diamond, SuitEnum.Club }; foreach (var suit in suits) { if (!(grid.Card1AvaliableSuits.Contains(suit) && grid.Card2AvaliableSuits.Contains(suit))) { switch (suit) { case SuitEnum.Heart: result.HeartStatus = BoardRangeGridStatusEnum.Unavailable; break; case SuitEnum.Spade: result.SpadeStatus = BoardRangeGridStatusEnum.Unavailable; break; case SuitEnum.Diamond: result.DiamondStatus = BoardRangeGridStatusEnum.Unavailable; break; case SuitEnum.Club: result.ClubStatus = BoardRangeGridStatusEnum.Unavailable; break; } continue; } var hole1 = new Card(suit, grid.HighRank); var hole2 = new Card(suit, grid.LowRank); var outcome = TestGridAgainstBoard(hole1, hole2).Item1; switch (suit) { case SuitEnum.Heart: result.HeartStatus = TranslateOutcomeToGridStatus(outcome); break; case SuitEnum.Spade: result.SpadeStatus = TranslateOutcomeToGridStatus(outcome); break; case SuitEnum.Diamond: result.DiamondStatus = TranslateOutcomeToGridStatus(outcome); break; case SuitEnum.Club: result.ClubStatus = TranslateOutcomeToGridStatus(outcome); break; } } return(result); }
public Card(SuitEnum newsuit, int newrank, ColorEnum newcolor, Sprite newsprite) { suit = newsuit; rank = newrank; color = newcolor; card_sprite = newsprite; }
public Deck() { Random rand = new Random(); Cards = new List <Card>(); List <int> possibleSuit = Enumerable.Range(1, 4).ToList(); List <int> listNumberSuite = new List <int>(); for (int i = 0; i < 4; i++) { int index = rand.Next(0, possibleSuit.Count); listNumberSuite.Add(possibleSuit[index]); SuitEnum suit = (SuitEnum)possibleSuit[index]; possibleSuit.RemoveAt(index); List <int> possibleDeck = Enumerable.Range(1, 13).ToList(); List <int> listNumberDeck = new List <int>(); for (int j = 0; j < 13; j++) { int indexDeck = rand.Next(0, possibleDeck.Count); listNumberDeck.Add(possibleDeck[indexDeck]); ValueEnum deck = (ValueEnum)possibleDeck[indexDeck]; Cards.Add(new Card(suit, deck)); possibleDeck.RemoveAt(indexDeck); } } foreach (Card c in Cards) { Console.WriteLine(c.Display()); } }
public Deck() { Random rand = new Random(); Cards = new List <Card>(); List <int> listNumberSuite = new List <int>(); List <int> listNumberDeck = new List <int>(); int number; for (int i = 0; i < 4; i++) { do { number = rand.Next(1, 4); } while (listNumberSuite.Contains(number)); SuitEnum suit = (SuitEnum)number; int deckNumber; for (int j = 0; j < 13; j++) { do { deckNumber = rand.Next(1, 13); } while (listNumberDeck.Contains(deckNumber)); ValueEnum deck = (ValueEnum)deckNumber; Cards.Add(new Card(suit, deck)); } } foreach (Card c in Cards) { Console.WriteLine(c.Display()); } }
private void CreateDeckSuit(SuitEnum suit, int step) { for (int i = 0; i < Constants.SUIT_SIZE; i++) { Cards[i + Constants.SUIT_SIZE * step] = new Card(i + 1, suit); } }
/// <summary> /// Create a new instance of a Card object. /// </summary> /// <param name="suit"></param> /// <param name="cardName"></param> /// <param name="cardValueManager"></param> public Card(SuitEnum suit, CardEnum cardName, ICardValueManager cardValueManager) { // Store the parameters this.Suit = suit; this.CardName = cardName; this.CardValueManager = cardValueManager; }
/// <summary> /// At least 3 cards are of the same suit /// </summary> /// <param name="fullBoard"></param> /// <param name="suit"></param> /// <returns></returns> private bool FullBoardHasThreeSuitedCards(List <Card> fullBoard, out SuitEnum suit, out int suitedCount) { suit = SuitEnum.Undefined; suitedCount = fullBoard.Count(c => c.Suit == SuitEnum.Heart); if (suitedCount >= 3) { suit = SuitEnum.Heart; return(true); } suitedCount = fullBoard.Count(c => c.Suit == SuitEnum.Spade); if (suitedCount >= 3) { suit = SuitEnum.Spade; return(true); } suitedCount = fullBoard.Count(c => c.Suit == SuitEnum.Diamond); if (suitedCount >= 3) { suit = SuitEnum.Diamond; return(true); } suitedCount = fullBoard.Count(c => c.Suit == SuitEnum.Club); if (suitedCount >= 3) { suit = SuitEnum.Club; return(true); } return(false); }
/// <summary> /// PK on a board that has at least three cards of the same suit /// </summary> /// <param name="heroHoles"></param> /// <param name="villainGrid"></param> /// <param name="fullBoard"></param> /// <param name="suit"></param> /// <returns></returns> private PkResult PkOnSuitedBoard(HoldingHoles heroHoles, PlayerRangePkGrid villainGrid, List <Card> fullBoard, SuitEnum suit) { var heroOffsuitRanks = fullBoard.Select(c => c.Rank).ToList(); heroOffsuitRanks.Add(heroHoles.Hole1.Rank); heroOffsuitRanks.Add(heroHoles.Hole2.Rank); var heroSuitedRanks = fullBoard.Where(c => c.Suit == suit).Select(c => c.Rank).ToList(); if (heroHoles.Hole1.Suit == suit) { heroSuitedRanks.Add(heroHoles.Hole1.Rank); } if (heroHoles.Hole2.Suit == suit) { heroSuitedRanks.Add(heroHoles.Hole2.Rank); } var heroOffsuitHand = _offsuitHandFinder.FindBestHand(heroOffsuitRanks); var heroSuitedHand = _suitedHandFinder.FindBestHand(heroSuitedRanks); IHand heroBestHand = heroSuitedHand == null ? heroOffsuitHand : (heroSuitedHand.CompareTo(heroOffsuitHand) > 0 ? heroSuitedHand : heroOffsuitHand); var pkResult = PkHeroHandOnSuitedBoard(heroBestHand, villainGrid, fullBoard, suit); return(pkResult); }
/// <summary> /// This method returns the Suit for the cardNumber given. /// This is used for new deck initialization only and this is not inteneded to be called after a deck is shuffled. /// <param name="cardNumber">The ordinal position of the card where 1 is the first card and 52 is the last card.</param> /// </summary> private SuitEnum GetSuit(int cardNumber) { // initial value SuitEnum suit = SuitEnum.Unknown; // if the cardNumber is higher than where Spades start if (cardNumber > 39) { // set to spades suit = SuitEnum.Spades; } else if (cardNumber > 26) { // set to Hearts suit = SuitEnum.Hearts; } else if (cardNumber > 13) { // Set to Diamonds suit = SuitEnum.Diamonds; } else if (cardNumber > 0) { // Must be Clubs suit = SuitEnum.Clubs; } // return value return(suit); }
private string GetName(int value, SuitEnum suit) { var suitName = Enum.GetName(typeof(SuitEnum), suit); if (value >= 2 && value <= 10) { return($"{value} {suitName}"); } var newVal = string.Empty; switch (value) { case 11: newVal = "J"; break; case 12: newVal = "Q"; break; case 13: newVal = "K"; break; case 14: newVal = "A"; break; } return($"{newVal} {suitName}"); }
public Card(SuitEnum cardSuit, RankEnum cardRank) { CardSuit = cardSuit; CardRank = cardRank; CardName = CardSuit + " " + CardRank; CardValue = GetCardValue(); }
/// <summary> /// Constructor. /// </summary> /// <param name="number"></param> /// <param name="suit"></param> public Card(CardEnum number, SuitEnum suit) { Number = number; Suit = suit; // Gets the value depending on the card number switch (Number) { case (CardEnum.Two): case (CardEnum.Three): case (CardEnum.Four): case (CardEnum.Five): case (CardEnum.Six): case (CardEnum.Seven): case (CardEnum.Eight): case (CardEnum.Nine): case (CardEnum.Ten): Value = (int)Number; break; case (CardEnum.J): case (CardEnum.Q): case (CardEnum.K): Value = 10; break; case (CardEnum.Ace): Value = 11; break; default: Value = 0; break; } }
public void Setup(SuitEnum _suit, RankEnum _rank) { suit = _suit; rank = _rank; cardName = "" + rank.ToString() + " of " + suit.ToString(); gameObject.name = cardName; GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Card_Fronts/" + suit.ToString()[0] + (int)rank); }
/// <summary> /// This method return the value for seven. /// </summary> public override double GetCountValueOfSeven(SuitEnum suit = SuitEnum.Unknown) { // initial value double valueOfSeven = DefaultValueOfSeven; // return the defaut value for a Seven return(valueOfSeven); }
/// <summary> /// This method return the value for twos. /// </summary> public override double GetCountValueOfFive(SuitEnum suit = SuitEnum.Unknown) { // initial value double valueOfFive = DefaultValueOfFive; // return the defaut value for an Two return(valueOfFive); }
public void GetSuit_SuitWithCorrectCharactersGenerated(SuitEnum suit, char expectedChar) { var factory = ConstructSuitFactory(); var character = factory.GetSuit(suit).AsCharacter(); Assert.Equal(expectedChar.ToString(), character.ToString()); }
public void ISuitEqual_NextSuitEnum(SuitEnum firstSuit, SuitEnum secondSuit, bool expectedEqual) { var suit1 = new Suit(' ', 0, firstSuit); var suit2 = new Suit(' ', 0, secondSuit); var areEqual = suit1.Equals(suit2); Assert.Equal(expectedEqual, areEqual); }
public void SetSuitUnlessForSuitedGrid(SuitEnum suit, T set, Func <T, bool> unless) { if (Category != GridCategoryEnum.Suited) { throw new InvalidOperationException(); } SuitedStatus.SetSuitUnless(suit, set, unless); }
public void SetFirstSuitUnlessForOffsuitGrid(SuitEnum suit, T set, Func <T, bool> unless) { if (Category != GridCategoryEnum.Offsuit) { throw new InvalidOperationException(); } OffsuitStatus.SetAllUnless(set, unless); }
private IHand FindBestHand(HoldingHoles holes, List <Card> fullBoard, SuitEnum suit) { var bestOffsuitHand = FindBestOffsuitHand(holes, fullBoard); var bestSuitedHand = FindBestSuitedHand(holes, fullBoard, suit); return(bestSuitedHand == null ? bestOffsuitHand : (bestSuitedHand.CompareTo(bestOffsuitHand) > 0 ? bestSuitedHand : bestOffsuitHand)); }
public SuitedThreeSuitTexture(FlopBoard flopBoard) { if (flopBoard.Flop1.Suit != flopBoard.Flop2.Suit || flopBoard.Flop2.Suit != flopBoard.Flop3.Suit) { throw new InvalidOperationException("Off suit"); } Card1 = flopBoard.Flop1; Card2 = flopBoard.Flop2; Card3 = flopBoard.Flop3; Suit = Card1.Suit; }
private NotifyHeroHolesRequest GenerateHeroHolesRequest(Guid roundId, SuitEnum suit1, RankEnum rank1, SuitEnum suit2, RankEnum rank2) { return(new NotifyHeroHolesRequest() { RoundId = roundId, Holes = new List <Card> { new Card(suit1, rank1), new Card(suit2, rank2) } }); }
public Card(char rank, char suit) { CardValueEnum _rank = rankParseLookup[rank]; SuitEnum _suit = suitParseLookup[suit]; _card = (CardEnum)((int)_suit + (int)_rank); if (_suit == SuitEnum.Unknown || _rank == CardValueEnum.Unknown) { throw new ArgumentException("Hand is not correctly formatted. Value: " + rank + " Suit: " + suit); } }
/// <summary> /// The constructor used to build a card. /// </summary> /// <param name="suit">The suit of the card.</param> /// <param name="symbol">The symbol of the card.</param> public Card( SuitEnum suit, SymbolEnum symbol) { Suit = suit; Symbol = symbol; SuitString = suit.ToString(); SymbolString = symbol.ToString(); CardValue = (int)symbol; IsAce = Symbol == SymbolEnum.Ace; IsFaceCard = Value >= (int)SymbolEnum.Jack; }
private static SuitEnum[] initSuitParseLookup() { SuitEnum[] suits = new SuitEnum[128]; suits['C'] = SuitEnum.Clubs; suits['c'] = SuitEnum.Clubs; suits['D'] = SuitEnum.Diamonds; suits['d'] = SuitEnum.Diamonds; suits['H'] = SuitEnum.Hearts; suits['h'] = SuitEnum.Hearts; suits['S'] = SuitEnum.Spades; suits['s'] = SuitEnum.Spades; return(suits); }
public void CreateDecks(int DeckAmount) { var combinedDecks = new List <Card>(); foreach (SuitEnum suit in SuitEnum.GetValues(typeof(SuitEnum))) { foreach (FaceValueEnum faceValue in FaceValueEnum.GetValues(typeof(FaceValueEnum))) { combinedDecks.AddRange(Enumerable.Repeat(new Card(suit, faceValue), DeckAmount)); } } Cards = combinedDecks; }
public Card(int numericValue, SuitEnum suit, NameEnum cardName) { if (numericValue == 1) { NumericValue = 11; } else { NumericValue = numericValue; } SuitNumeric = suit; NameAlphabetic = cardName; }
/// <summary> /// This method return the value for twos. In KISS II Red 2's count as a 1 /// and black 2's count as a zero /// </summary> public override double GetCountValueOfTwo(SuitEnum suit = SuitEnum.Unknown) { // initial value int valueOfTwo = DefaultValueOfBlackTwo; // if 'Red' - Daimonds or Hearts if ((suit == SuitEnum.Diamonds) || (suit == SuitEnum.Hearts)) { // Change the value to a Red Two (1) valueOfTwo = DefaultValueOfRedTwo; } // return the defaut value for an Two return(valueOfTwo); }
private IHand FindBestSuitedHand(HoldingHoles holes, List <Card> fullBoard, SuitEnum suit) { var suitedRanks = fullBoard.Where(c => c.Suit == suit).Select(c => c.Rank).ToList(); if (holes.Hole1.Suit == suit) { suitedRanks.Add(holes.Hole1.Rank); } if (holes.Hole2.Suit == suit) { suitedRanks.Add(holes.Hole2.Rank); } return(_suitedHandFinder.FindBestHand(suitedRanks)); }
private Card(SuitEnum suit, CardValueEnum rank) { _card = (CardEnum)((int)suit + (int)rank); }
private static SuitEnum[] initSuitParseLookup() { SuitEnum[] suits = new SuitEnum[128]; suits['C'] = SuitEnum.Clubs; suits['c'] = SuitEnum.Clubs; suits['D'] = SuitEnum.Diamonds; suits['d'] = SuitEnum.Diamonds; suits['H'] = SuitEnum.Hearts; suits['h'] = SuitEnum.Hearts; suits['S'] = SuitEnum.Spades; suits['s'] = SuitEnum.Spades; return suits; }
public static CardInfo[] By(SuitEnum suit, params CardInfo.RankEnum[] rank) { return rank.ToArray(z => new CardInfo(suit, z)); }
public Value(SuitEnum suit, RankEnum rank) { _suit = suit; _rank = rank; }
public Card(SuitEnum suit, RankEnum rank) { Suit = suit; Rank = rank; }
public Card(SuitEnum suit, ValueEnum val) { this.Suit = suit; this.Value = val; }
public Card(int value, SuitEnum suit) { Value = value; Suit = suit; }
public static CardInfo[] By(SuitEnum suit, params CardInfo.RankEnum[] rank) { var a = new List<CardInfo>(); foreach (var z in rank) { var c = new CardInfo(suit, z); a.Add(c); } return a.ToArray(); }