Ejemplo n.º 1
0
 /// <summary>
 /// Set the cards in the deck to default order.
 /// </summary>
 void ResetDeck()
 {
     foreach (CardFace face in CardFace.EnumerateCardFaces())
     {
         deck[face.GetUniqueId()] = cards[face];
     }
     version++;
 }
Ejemplo n.º 2
0
    int version = 0; // Used to throw an exception when enumerating through a deck that has been altered mid-enumeration.

    public Deck(IDictionary <CardFace, GameObject> cardModels, ICardFactory factory)
    {
        if (cardModels == null)
        {
            throw new ArgumentNullException("cardModels");
        }
        if (factory == null)
        {
            throw new ArgumentNullException("factory");
        }

        foreach (var pair in cardModels)
        {
            CardFace   face   = pair.Key;
            GameObject prefab = pair.Value;
            cards[pair.Key] = CreateCard(face, prefab, factory);
        }

        Assert.IsTrue(CardFace.EnumerateCardFaces().All(cards.ContainsKey));

        ResetDeck();
    }