Esempio n. 1
0
        public PlayingCard GetCardById(string id)
        {
            PlayingCard result = null;

            cardDict.TryGetValue(id, out result);
            if (result == null)
            {
                Debug.LogError("Card with id " + id + " is not in the deck!");
            }
            return(result);
        }
Esempio n. 2
0
        public Stack <PlayingCard> Shuffle(Stack <PlayingCard> deck)
        {
            PlayingCard[]       tempDeck = deck.ToArray();
            Stack <PlayingCard> result   = new Stack <PlayingCard>();

            for (int i = 0; i < tempDeck.Length; i++)
            {
                int         newPlace = Random.Range(0, tempDeck.Length - 1);
                PlayingCard temp     = tempDeck[newPlace];
                tempDeck[newPlace] = tempDeck[i];
                tempDeck[i]        = temp;
            }
            for (int i = 0; i < tempDeck.Length; i++)
            {
                result.Push(tempDeck[i]);
            }
            return(result);
        }
Esempio n. 3
0
        public CardDeck(PlayingCard[] pregen, int number)
        {
            cards    = new Stack <PlayingCard>();
            grave    = new Stack <PlayingCard>();
            cardDict = new Dictionary <string, PlayingCard>();

            for (int i = 0; i < pregen.Length; i++)
            {
                cards.Push(pregen[i]);
                //Debug.Log("Added a card");
                cardDict.Add(pregen[i].id, pregen[i]);
            }

            for (int i = 0; i < number - pregen.Length; i++)
            {
                cards.Push(PlayingCard.GetBalancedCard(3, 9));
            }
            cards = Shuffle(cards);
        }
Esempio n. 4
0
 public bool inGrave(PlayingCard card)
 {
     return(grave.Contains(card));
 }
Esempio n. 5
0
 public void Bury(PlayingCard card)
 {
     grave.Push(card);
     Debug.Log("Card " + card.ToString() + "put into grave");
 }