Exemplo n.º 1
0
        /// <summary>
        /// Move all card to the deck.
        /// </summary>
        /// <param name="to">Target deck.</param>
        public void MoveAll(CardDeck to)
        {
            if (to.size >= 0 && to.list.Count() > to.size - this.list.Count)
            {
                throw GameException.getCardTooManyException();
            }
            List <string> list = new List <string>();

            foreach (Card card in this.list)
            {
                list.Add(card.Name);
            }
            foreach (string name in list)
            {
                this.Move(name, to);
            }
        }
Exemplo 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);
        }