Exemple #1
0
    public void Draw(int numOfCards)
    {
        int i = numOfCards;

        while (i > 0)
        {
            if (drawPile.IsEmpty())
            {
                // Special case where the draw pile and discard pile are both empty and therefore remaining draws cannot occur.
                if (discardPile.IsEmpty())
                {
                    return;
                }
                // Draw pile is empty; copy all card references from discard pile to draw pile and shuffle the draw pile, then clear out the discard pile.
                drawPile.deck.AddRange(discardPile.deck);
                drawPile.Shuffle();
                discardPile.deck.Clear();
            }

            // Actually add the card from the draw pile to your hand if it's not at max size, else it goes straight to discard.
            AbstractCard drawnCard = drawPile.PopTopCard();
            drawnCard.OnDraw(this);     // Trigger on-draw modifier for the card, supplying the current character.
            if (hand.Count < 10)
            {
                hand.Add(drawnCard);
            }
            else
            {
                discardPile.AddCard(drawnCard);
            }
            i--;        // Repeat process <numOfCards> times.
        }
        return;
    }
Exemple #2
0
 /// <summary>
 /// 往手牌中添加手牌。多余手牌上限将弃牌。
 /// </summary>
 /// <param name="index"></param>
 /// <param name="card"></param>
 public override void Add(int index, AbstractCard card)
 {
     if (_deck.Count >= 10)
     {
         if (card is AbstractWeapon)
         {
             Owner.ArmoryGrave.Add(card);
         }
         else
         {
             Owner.Grave.Add(card);
         }
     }
     else
     {
         base.Add(index, card);
         card.OnDraw(Owner, card.Target);
     }
 }