public bool TryTakeCard(out PlayingCard card) { if (deck.Count == 0) { card = null; return(false); } card = deck[deck.Count - 1]; deck.RemoveAt(deck.Count - 1); return(true); }
private static PlayingCard[] GenerateAllCards() { PlayingCard[] array = new PlayingCard[52]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 13; j++) { array[i * 13 + j] = new PlayingCard((Suit)i, (Rank)j); } } return(array); }
public DeckOfCards() { deck = new List <PlayingCard>(52); for (int i = 0; i < 4; i++) { for (int j = 0; j < 13; j++) { deck.Add(PlayingCard.GetCard(i, j)); } } ShuffleDeck(); }
public void ShuffleDeck() { int num = deck.Count; while (num > 1) { num--; int index = Random.Range(0, num); PlayingCard value = deck[index]; deck[index] = deck[num]; deck[num] = value; } }
public void AddCard(PlayingCard card) { deck.Insert(0, card); }