Ejemplo n.º 1
0
        /// <summary>
        /// Draw a card from this talon and send it to another deck.
        /// </summary>
        /// <param name="to">The deck to send the card.</param>
        /// <returns>Drawn card.</returns>
        public Card Draw(CardDeck to)
        {
            if (this.list.Count() == 0)
            {
                throw GameException.getNoCardException();
            }
            Card card = this.list.First();

            CardDeck.handler(this, to, card);
            this.Move(card.Name, to);
            return(card);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Move the specified card to the another deck.
        /// </summary>
        /// <param name="cardStr">card string.</param>
        /// <param name="to">Target deck.</param>
        /// <returns>Card instance.</returns>
        public Card Move(string cardStr, CardDeck to)
        {
            if (to.size >= 0 && to.list.Count() == to.size)
            {
                throw GameException.getCardTooManyException();
            }

            Card card = this.Get(cardStr);

            if (card == null)
            {
                throw GameException.getNoCardException();
            }

            if (!this.list.Remove(card))
            {
                throw new Exception();
            }
            CardDeck.handler(this, to, card);
            to.list.Add(card);
            return(card);
        }