public Card[] DistributeCards(int i, Card.Suit suitReq) { Card[] r = new Card[i]; for (int j = 0; j < i; j++) { // break out if we are out of cards if (distroKeys.Count <= 0) { break; } Card.Suit s = distroKeys[(int)Random.Range(0, distroKeys.Count)]; if (j == 0 && distroKeys.Contains(suitReq)) { s = suitReq; } List <Card> q = distroQueues[s]; r[j] = q[q.Count - 1]; q.RemoveAt(q.Count - 1); //handle running out of cards if (q.Count <= 0) { distroKeys.Remove(s); } } return(r); }
public static int ScoreingValue(Card c, StateMachineSystem.StateMachine targetMachine) { Card.Suit trump = targetMachine.Memory.GetData <Card.Suit>("Trump"); Card lead = targetMachine.Memory.GetData <List <Card> >("Plays")[0]; //Intial value is as printed on the card int val = (int)c.value; //If on suit, add value if (c.suit == lead.suit) { val += 20; } //If on trump, add value if (c.suit == trump) { val += 50; } //Override on-color Jack if (c.suit == trump.SameColorSuit() && c.value == Card.Value.Jack) { val = 200; } //Override on-trump Jack if (c.suit == trump && c.value == Card.Value.Jack) { val = 250; } return(val); }
public void recolorTextUI(Card.Suit suit) { switch (suit) { case Card.Suit.CLUBS: this.GetTextMeshUI().color = CLUBS; this.GetTextMeshUI().fontSharedMaterial = GetMatClubs(); break; case Card.Suit.SPADES: this.GetTextMeshUI().color = SPADES; this.GetTextMeshUI().fontSharedMaterial = GetMatSpades(); break; case Card.Suit.HEARTS: this.GetTextMeshUI().color = HEARTS; this.GetTextMeshUI().fontSharedMaterial = GetMatHearts(); break; case Card.Suit.DIAMONDS: this.GetTextMeshUI().color = DIAMONDS; this.GetTextMeshUI().fontSharedMaterial = GetMatDiamonds(); break; } }
public void SetSoldierModel(Card.Suit suit, int playerNo, int rank) { if (soldierModel != null) { Destroy(soldierModel); Debug.Log("Destroyed"); } soldierModel = null; weapons = null; if (rank < 0) { return; } soldierModel = Instantiate(General.GetSoldierModelPrefab(suit, playerNo), meshParent.transform); Transform weaponsParent = soldierModel.FindComponentInChildWithTag <Transform>("Weapon"); weapons = new GameObject[weaponsParent.childCount]; for (int i = 0; i < weapons.Length; i++) { weapons[i] = weaponsParent.GetChild(i).gameObject; weapons[i].SetActive(false); } //Debug.Log("Spawning soldier: "+suit+" || Rank "+rank); weapons[rank - 1].SetActive(true); }
private Deck() { cards = new Card[52]; // Add the 13 cards for each suit into the deck int index = 0; for (int i = 0; i < 4; i++) { Card.Suit suit = (Card.Suit)i; for (int j = 0; j < 13; j++) { Card.Rank rank = (Card.Rank)j; cards[index] = new Card(suit, rank); index++; } } if (DebugObject.Instance.DEBUG_MODE) { for (int i = 0; i < Mathf.Min(DebugObject.Instance.debugCardRanks.Length, DebugObject.Instance.debugCardSuits.Length); i++) { cards[i] = new Card(DebugObject.Instance.debugCardSuits[i], DebugObject.Instance.debugCardRanks[i]); Debug.Log("Replacing card " + i + " with " + cards[i]); } } ShuffleDeck(); }
public void SetAvatar(Card.Suit suit) { switch (suit) { case Card.Suit.CLUBS: SetAvatar(CLUBS); break; case Card.Suit.HEARTS: SetAvatar(HEARTS); break; case Card.Suit.DIAMONDS: SetAvatar(DIAMONDS); break; case Card.Suit.SPADES: SetAvatar(SPADES); break; default: SetAvatar(NONE); break; } }
public static GameObject SpawnTrumpIndicator(Card.Suit suit, int team) { GameObject spawnedObject = Instantiate(instance.trumpStamps[(int)suit]); spawnedObject.GetComponent <SpriteRenderer>().color = (team == 0) ? PlayerColor : OpponentColor; return(spawnedObject); }
public void ResetDeck() { deck = new Stack <Card>(); Card[] cards = new Card[52]; int count = 0; for (int i = 0; i < 4; i++) { //Get the enum value of the suit Card.Suit suit = (Card.Suit)i; for (int value = 2; value < 15; value++) { //Add the new card to the deck cards[count] = new Card(suit, value); count++; } } cards = ShuffleDeck(cards); foreach (Card card in cards) { deck.Push(card); } }
private Card.Rank[] GetFlushRanks(List <Card> pokerHand, int[] numberEachSuit) { Card.Suit flushSuit = Card.Suit.none; List <Card> flushHand = new List <Card>(); Card.Rank[] highestRanks = new Card.Rank[] { Card.Rank.none, Card.Rank.none, Card.Rank.none, Card.Rank.none, Card.Rank.none }; for (int i = 0; i < numberEachSuit.Length; i++) { if (numberEachSuit[i] >= 5) { flushSuit = (Card.Suit)i; } } foreach (Card el in pokerHand) { if (el.GetSuit() == flushSuit) { flushHand.Add(el); } } var sortedFlushHand = flushHand.OrderByDescending(x => (int)(x.GetRank())).ToList(); for (int i = 0; i < 5; i++) { highestRanks[i] = sortedFlushHand[i].GetRank(); } return(highestRanks); }
public CardData(Card.Suit suit, Card.Rank rank, bool shown = true) { this.suit = suit; this.rank = rank; value = (int)suit + (int)rank * Enum.GetValues(typeof(Card.Suit)).Length; isShown = shown; }
private static int CalculateHandPoints(List <Card> hand, Card upCard, Card.Suit suitInQuestion, bool dealerOnTeam, PointSpread pointSpread) { int ret = 0; //Calulate the face up card going to a player ret += CardValue(upCard, suitInQuestion, pointSpread) * ((dealerOnTeam) ? 1 : -1); List <Card.Suit> uniqueSuits = new List <Card.Suit>(); foreach (Card card in hand) { if (uniqueSuits.Contains(card.suit) == false) { uniqueSuits.Add(card.suit); } ret += CardValue(card, suitInQuestion, pointSpread); } if (uniqueSuits.Count <= 2) { ret += pointSpread.TwoSuited; } { string debugPrint = "Suit: " + suitInQuestion.Shortname() + " Points: " + ret + "\n Hand:"; foreach (Card card in hand) { debugPrint += card.Shortname(); debugPrint += ","; } //Debug.Log(debugPrint); } return(ret); }
private void TroefLeftButtonDown(object sender, MouseButtonEventArgs e) { if (GS.GamePhase == "Troef10User") { Image img = (Image)sender; int num = Convert.ToInt32(img.Name.Substring(4)); Card.Suit troef = GS.Troef[GS.TroefNum].Kaart.Soort; if (GS.TroefNum >= num && GS.Troef[num].Kaart.Soort == troef) { int troefID = GS.Troef[num].Kaart.ID; int troef10num = -1; int troef10ID = 0; for (int count = 0; count < 3; count++) { if (GS.UserHand[count].Kaart.Soort == troef && GS.UserHand[count].Kaart.Punten == 0) { troef10num = count; troef10ID = GS.UserHand[count].Kaart.ID; } } GS.Troef[num].Kaart.Change(troef10ID); GS.UserHand[troef10num].Kaart.Change(troefID); GS.PlayerHand[3].RemoveAt(troef10num); GS.PlayerHand[3].Add(new Card(troefID)); GS.Troef[num].Border = GS.zwart; GS.ClearTable(); GS.ButtonTopTxt = " "; GS.ButtonBottomTxt = " "; GS.MsgTxt = " "; GS.ZwikCheck(); } } }
public Card GetCard(Card.Suit suit, Card.Rank rank) { Card card = cardsDict[cardNamePrefix + Enum.GetName(typeof(Card.Suit), suit) + Enum.GetName(typeof(Card.Rank), rank)]; deckCardsList.Remove(card); return(card); }
private void IncrementProgress(Card.Suit suit) { Progress[suit]++; PushUndoable(delegate() { Progress[suit]--; }); }
public void TestGetSetCard(Card.Suit suit, Card.Value value) { Card card = new Card(0, 0); card.CardSuit = suit; card.CardValue = value; Assert.True(card.CardSuit == suit && card.CardValue == value); }
private void CreateCard(GameObject cardPrefab, Card.Suit suit) { GameObject card = Instantiate(cardPrefab); Card cardScript = card.GetComponent <Card>(); cardScript.CardSuit = suit; cards.Add(cardScript); }
public void SetTextUI(string healthText, Card.Suit suit) { if (suit == Card.Suit.HEARTS) // Hearts shouldn't have text { healthText = ""; } this.SetTextUI(healthText); }
public Sprite GetCardSprite(Card.Suit suit, Card.Value value) { int suiteOffset = (int)suit * 14; int cardOffset = (int)value; int offset = suiteOffset + cardOffset; return(cardSprites[offset]); }
public void PlayFireSound(Card.Suit suit) { switch (suit) { default: SoundManager.Instance.Play(AudibleNames.Fire.DEFAULT); break; } }
public void OnDrop(Card cardToDrop) { if (CanDrop(cardToDrop)) { cards.Add(cardToDrop); lastCardValue = cardToDrop.CardValue; stackSuit = cardToDrop.CardSuit; } }
public static bool isValidPlay(Card c, Player p, StateMachineSystem.StateMachine targetMachine) { Card.Suit trump = targetMachine.Memory.GetData <Card.Suit>("Trump"); List <Card> plays = targetMachine.Memory.GetData <List <Card> >("Plays"); if (plays.Count > 0) { bool hasLeadSuitInHand = false; //Figure out the lead suit Card.Suit leadSuit = plays[0].suit; //overide the lead suit for offsuit Trump jack if (plays[0].value == Card.Value.Jack && plays[0].suit == trump.SameColorSuit()) { leadSuit = trump; } //Figure out the suit of what we playes Card.Suit playedSuit = c.suit; //Override the played suit for offsuit trump jack if (c.value == Card.Value.Jack && c.suit == trump.SameColorSuit()) { playedSuit = trump; } //Check if the hand has a card that is valid suit foreach (Card card in p.GetHand()) { Card.Suit cardsSuit = card.suit; //Overrride the offsuit Trump jack if (card.value == Card.Value.Jack && card.suit == trump.SameColorSuit()) { cardsSuit = trump; } if (cardsSuit == leadSuit) { hasLeadSuitInHand = true; } } //If they have an on suit play at the played card isn't, invalidate the play if (hasLeadSuitInHand && playedSuit != leadSuit) { return(false); } else { return(true); } } else { return(true); } }
public void SetTextUI(string attackText, Card.Suit suit) { if (suit == Card.Suit.HEARTS) // Hearts shouldn't have text { attackText = ""; } this.SetTextUI(attackText); this.recolorTextUI(suit); }
public void PlayFlushFX(HandType handType, Card.Suit suit) { if (handType != HandType.Flush) { return; } PlayComboFX(handType); iconHand.sprite = flushIconDictionary[suit]; }
public static Card[] RetrieveCommunityCards() { Bitmap currentCommunityCards = CaptureCommunityCardsImage(); int foundCount = 0; int cardsToSearch; Card[] hand; //Check to see how many cards you need to find, if no cards are on the table return null. if (BitmapHandler.SearchBitmap(currentCommunityCards, RetrieveBitmap("3cards"))) { cardsToSearch = 3; hand = new Card[3]; } else if (BitmapHandler.SearchBitmap(currentCommunityCards, RetrieveBitmap("4cards"))) { cardsToSearch = 4; hand = new Card[4]; } else if (BitmapHandler.SearchBitmap(currentCommunityCards, RetrieveBitmap("5cards"))) { cardsToSearch = 5; hand = new Card[5]; } else { return(null); } foreach (NamedBitmap cardImage in cardPics) { if (BitmapHandler.SearchBitmap(currentCommunityCards, cardImage.bitmap)) { //Split the Bitmap filenames up into two seperate strings. EX) filename == S7, then stringSuit = "S", and stringRank = "7" string stringSuit = cardImage.name.Substring(0, 1); string stringRank = cardImage.name.Substring(1); //Get the Bitmap filenames into Suit and Rank Enums. EX) filename == S7, then cardSuit = Suit.Spades, and cardRank = Rank.Seven Card.Suit cardSuit = ConvertStringToSuit(stringSuit); Card.Rank cardRank = ConvertStringToRank(stringRank); hand[foundCount] = new Card(cardSuit, cardRank); foundCount++; //If you found all the cards, stop searching if (foundCount == cardsToSearch) { break; } } } return(hand); }
// should probably change this to do a binary search. public bool ContainsSuit(Card.Suit suit) { foreach (Card item in hand) { if (item.SUIT.Equals(suit)) { return(true); } } return(false); }
// If all cards' suits match the first card, it is a flush private static bool IsHandFlush(Card[] rankSortedHand) { Card.Suit suit = rankSortedHand[0].suit; foreach (Card c in rankSortedHand) { if (c.suit != suit) { return(false); } } return(true); }
public bool HasFlush() { Card.Suit flushSuit = Cards[0].suit; for (int index = 1; index < Cards.Count; index++) { if (flushSuit != Cards[index].suit) { return(false); } } return(true); }
private void Troef_MouseLeave(object sender, MouseEventArgs e) { if (GS.GamePhase == "Troef10User") { Image img = (Image)sender; int num = Convert.ToInt32(img.Name.Substring(4)); Card.Suit troef = GS.Troef[GS.TroefNum].Kaart.Soort; if (GS.TroefNum >= num && GS.Troef[num].Kaart.Soort == troef) { GS.Troef[num].Border = GS.zwart; } } }
private static int CardValue(Card c, Card.Suit trump, PointSpread pointSpread) { int value = 0; if (c.suit == trump) { //On suit cards switch (c.value) { case Card.Value.Nine: value = pointSpread.Nine; break; case Card.Value.Ten: value = pointSpread.Ten; break; case Card.Value.Queen: value = pointSpread.Queen; break; case Card.Value.King: value = pointSpread.King; break; case Card.Value.Ace: value = pointSpread.Ace; break; case Card.Value.Jack: value = pointSpread.RightBower; break; } } else { //Off suit ace if (c.value == Card.Value.Ace) { value = pointSpread.OffSuitAce; } //Left Bower if (c.value == Card.Value.Jack && c.suit == trump.SameColorSuit()) { value = pointSpread.Ace; } } //Debug.Log("C:" + c.Shortname() + " T:" + trump + " P: " + value); //Default to worth of 0 return(value); }
public static string GetAttackUIQuote(int player, Card.Suit suit) { switch (suit) { case Card.Suit.CLUBS: return(GetClubsQuote(player)); case Card.Suit.DIAMONDS: return(GetDiamondsQuote(player)); case Card.Suit.SPADES: return(GetSpadesQuote(player)); case Card.Suit.HEARTS: return(GetHeartsQuote(player)); } return(UI_DEFAULT_QUOTE); }