private static IEnumerable <PokerDuel> ReadHandsFromFile() { const string filePath = "Data/Problem54Data.txt"; string[] rawText = File.ReadAllLines(filePath); // Convert each line into a poker hand. // Expecting 10 cards per line, separated by spaces in the format 'VS' where V is the value, S is the suit. foreach (string line in rawText) { var cardsInLine = new List <Card>(); for (int i = 0; i < line.Length; i += 3) { Card.FaceValue value = GetValue(line[i]); Card.CardSuit suit = GetSuit(line[i + 1]); cardsInLine.Add(new Card(value, suit)); } var handOne = new PokerHand(cardsInLine[0], cardsInLine[1], cardsInLine[2], cardsInLine[3], cardsInLine[4]); var handTwo = new PokerHand(cardsInLine[5], cardsInLine[6], cardsInLine[7], cardsInLine[8], cardsInLine[9]); yield return(new PokerDuel(handOne, handTwo)); } }
private void ComboFlush() { double nbr = LisCardOnBoard.Count / 2.0; int Middle = (int)Math.Ceiling(nbr); FlushCombo = LisCardOnBoard[Middle].Suit; }
/// <summary> /// Creates a card GameObject with <see cref="Card.CardRank"/> 'rank' /// and <see cref="Card.CardSuit"/> 'suit' and adds it to the card stack. /// </summary> private void CreateCard(Card.CardRank rank, Card.CardSuit suit) { GameObject CardGO = Instantiate(CardPrefab, transform.position, Quaternion.identity, transform); Card card = CardGO.GetComponent <Card>(); card.SetType(rank, suit); Cards.Push(card); }
/** * set trump for current game */ private void InitTrump() { GameObject trumpCardObj = GetTrumpCard(); this.trumpCardImg.GetComponent <Image>().sprite = trumpCardObj.GetComponent <Image>().sprite; this.trumpSuit = trumpCardObj.GetComponent <Card>().suit; }
public Suit(Card.CardSuit WhichSuit) { _Suit = WhichSuit; for (int i = 0; i < Suit.MAX_CARDS; i++) { _UndealtCards[i] = new Card(_Suit, i + 1); } }
public Sprite FindCardSprite(Card.CardValue v, Card.CardSuit s) { foreach (var item in commonFronts) { if (item.suit == s && item.value == v) { return(item.faceArt); } } return(null); }
public Card CreateCard(Card.CardSuit suit, Card.CardValue value) { //make sure we can find our prefab in resorces var _cardObj = Resources.Load("Prefabs/Card") as GameObject; if (_cardObj == null) { Debug.LogError("Unable to find card prefab"); return(null); } //now instatiate (creates an instance of that prefab and adds it to the scene) _cardObj = Instantiate(_cardObj); if (_cardObj == null) { Debug.LogError("Failed to create card prefab"); return(null); } //we will be using the "Card" component of the newly created card a few times, // GetComponent is expensive so we do it once and store it. Because _card was created in this function //it will get freed up after the funtion and destroyed. var _card = _cardObj.GetComponent <Card> (); if (_card == null) //if for some reason the card doesnt have a card class/component on it we will just add it. { _card = _cardObj.AddComponent <Card> (); } _card.CSuit = suit; _card.CValue = value; //now we want to set the name of the card so it makes sense as we look at it in the hierarchy //and set the parent to the deck, so all the cards get hidden underneath _cardObj.name = _card.CValue.ToString() + "_" + _card.CSuit.ToString(); _cardObj.transform.SetParent(transform, false); //we will now loop though all the children (possible card types) and //remove the ones we are not set to for this specific card. //this makes creating them a little heavier but ends up the cleanest so far for me. Transform _child = null; //loop though and destroy the kids we are not, that we dont need. for (int m = 0; m < _cardObj.transform.childCount; m++) { _child = _cardObj.transform.GetChild(m); if (_child.name != Card.CardBack && _child.name != _cardObj.name) { Destroy(_child.gameObject); } } return(_card); }
public TestPokerAI() { list = new List <Card>(); pokerCombo = new PokerAI(TypePlayerPoker.NORMAL); pokerCombo.CardsOnBoard = list; pokerTest = new PrivateObject(pokerCombo, new PrivateType(typeof(PokerAI))); cardRank = Card.CardRank.Two; cardSuit = Card.CardSuit.Clubs; imageBidon = Properties.Resources._2C; }
private bool checkRepeat(int rank, Card.CardSuit suit, int count) { for (int i = 0; i < count; ++i) { if (deck[i].rank == rank && deck[i].suit == suit) { return(true); } } return(false); }
public PokerAI(TypePlayerPoker CurrentType) : base() { Money = 1000; this.LisCardOnBoard = new List <Card>(); this.ListStraightCombo = new List <int>(); this.ListValue = new List <Card>(); this.ComboValuePoss = new List <Tuple <int, int> >(); this.FlushCombo = Card.CardSuit.Diamonds; this.WinProb = new List <double>(); this.CurrentType = CurrentType; }
private void InitCards() { //faces should be in order (1)from 6 to A, (2)from Spades -> Clubs -> Diamonds -> Hearts for (int i = 0; i < numOfCards; i++) { //Sprite sprite = faces[i]; int val = i / (numOfSuits) + lowestCardValue; Card.CardSuit suit = (Card.CardSuit)(i % numOfSuits); CardData cd = new CardData(val, suit); cards.Add(cd); } }
public char GetSuitSymbol(Card.CardSuit suit) { switch (suit) { case Card.CardSuit.Clubs: return('♣'); case Card.CardSuit.Spades: return('♠'); case Card.CardSuit.Hearts: return('♥'); case Card.CardSuit.Diamonds: return('♦'); default: return('?'); } }
public CardStack BuildDeck(bool shuffle, bool buildFaceUp = false) { CardStack deck = new CardStack(buildFaceUp); for (int iFace = 0; iFace < 4; iFace++) { Card.CardSuit suit = (Card.CardSuit)iFace; for (int iValue = 1; iValue <= 13; iValue++) { Card card = new Card(iValue, suit); deck.Add(card); } } if (shuffle) { deck = Shuffle(deck); } return(deck); }
public Player(Players players, int Value, Card.CardSuit Suite) { this.players = players; this.Value = Value; this.Suite = Suite; }
public CardData(int val, Card.CardSuit suit) { this.val = val; this.suit = suit; }
private void AddCardList(Card.CardRank rank, Card.CardSuit suit = Card.CardSuit.Clubs) { list.Add(new Card(rank, suit, imageBidon)); }