public List <Card> GetCardsByType(Card.CardTypeEnum type) { List <Card> rtrn = new List <Card>(); foreach (Card c in this.CardList) { if (c.Type == type) { rtrn.Add(c); } } return(rtrn); }
void DrawCards(HashSet <Card.CardTypeEnum> _cardsNoLongerAvailable) { if (_cardSlots == null || _cardSlots.Count == 0) { return; } HashSet <Card.CardTypeEnum> cardTypeDrawn = new HashSet <Card.CardTypeEnum>(); List <CardSlot> emptySlots = new List <CardSlot>(); List <Card.CardTypeEnum> allAvailableCards = CardDealer.Instance.CardDictionary.Keys.ToList(); foreach (Card.CardTypeEnum card in _cardsNoLongerAvailable) { allAvailableCards.Remove(card); } foreach (CardSlot cs in _cardSlots) { if (cs.DrawnCard != null) { cardTypeDrawn.Add(cs.DrawnCard.CardType); allAvailableCards.Remove(cs.DrawnCard.CardType); } else { emptySlots.Add(cs); } } foreach (CardSlot cse in emptySlots) { Card.CardTypeEnum randomAvailableCard = allAvailableCards[Random.Range(0, allAvailableCards.Count)]; if (CardDealer.Instance.CardDictionary.ContainsKey(randomAvailableCard)) { Card card = CardDealer.Instance.CardDictionary[randomAvailableCard]; allAvailableCards.Remove(randomAvailableCard); cse.DrawnCard = card; card.gameObject.SetActive(true); card.transform.SetParent(cse.transform, false); cse.CardBack.gameObject.SetActive(false); } } }
public void RemoveCardsByType(Card.CardTypeEnum type) { List <Card> removeList = this.GetCardsByType(type); removeList.ForEach(c => this.CardList.Remove(c)); }
//chooses the selected cards according to game's logic public void ChooseSelectedCard(List <Card> cards, Card.CardTypeEnum type, int roundtype) { bool check = false; List <Card> tempList; List <Card> tempList2 = null; Card minCard; if (roundtype == 1) { tempList = cards.Where(c => c.CardType >= type && (int)c.CardType != 1).ToList(); minCard = tempList.Min(); if (minCard != null) { minCard.Selected = true; } } else if (roundtype == 2) { int i = 0; int j = (int)type; while (j < 13 && check == false) { tempList = cards.Where(c => c.CardType >= type && (int)c.CardType != 1 && (int)c.CardType >= j).ToList(); minCard = tempList.Min(); if (minCard != null) { tempList2 = cards.Where(c => c.CardType == minCard.CardType).ToList(); } if (tempList2 != null && tempList2.Count() > 1) { foreach (Card card in tempList2) { if (i < 2) { card.Selected = true; i++; } } check = true; } j++; } } else if (roundtype == 3) { int i = 0; int j = (int)type; while (j < 13 && check == false) { tempList = cards.Where(c => c.CardType >= type && (int)c.CardType != 1 && (int)c.CardType >= j).ToList(); minCard = tempList.Min(); if (minCard != null) { tempList2 = cards.Where(c => c.CardType == minCard.CardType).ToList(); } if (tempList2 != null && tempList2.Count() > 2) { foreach (Card card in tempList2) { if (i < 3) { card.Selected = true; i++; } } check = true; } j++; } } }