Exemplo n.º 1
0
    /// <summary>
    /// Transfer the given card from source pile to target. Cannot transfer from a pile to itself. Card must
    /// belong to source, and not to target.
    /// </summary>
    /// <param name="mover">Specificies the movement logic used for this transfer.</param>
    /// <param name="source">Pile from which the card is being taken.</param>
    /// <param name="target">Pile the card is entering.</param>
    public void TransferCard(Card card, Mover mover, CardPile source, CardPile target)
    {
        if (card == null)
        {
            throw new ArgumentNullException("card");
        }

        if (mover == null)
        {
            throw new ArgumentNullException("mover");
        }

        ICardPile src = GetPile(source);
        ICardPile tar = GetPile(target);

        if (!src.Contains(card))
        {
            throw new ArgumentException("This card does not belong to the source pile.", "card");
        }

        if (tar.Contains(card))
        {
            throw new ArgumentException("This card already belongs to the target pile.", "card");
        }

        src.Remove(card);
        tar.Add(card, mover);
    }
Exemplo n.º 2
0
 public void DrawToMax(ICardPile <TCard> deck)
 {
     if (MaxCardNum != -1)
     {
         throw new NoMaximumDefinedException();
     }
     DrawToCount(deck, MaxCardNum);
 }
Exemplo n.º 3
0
 public void DrawToCount(ICardPile <TCard> deck, int count)
 {
     AssertCardNum(count);
     if (count != Count)
     {
         DrawFrom(deck, count - Count);
     }
 }
Exemplo n.º 4
0
        public void DrawFrom(ICardPile <TCard> deck, int num)
        {
            AssertCardNum(num);

            AddRange(deck.Draw(num));
        }
Exemplo n.º 5
0
 public void PlayCard(ICardPile <TCard> deck, TCard card)
 {
     AssertCard(card);
     Remove(card);
     deck.PutOnTop(card);
 }
Exemplo n.º 6
0
 public void DiscardTo(ICardPile <TCard> pile, IEnumerable <TCard> cards)
 {
     AssertCards(cards);
     pile.PutOnTop(cards);
 }
Exemplo n.º 7
0
 //Přidá do balíčku obsah discardpile a zamíchá karty
 public void Shuffle(ICardPile discardPile)
 {
     cards.AddRange(discardPile.GetCards());
     discardPile.Empty();
     cards.Shuffle();
 }