コード例 #1
0
ファイル: Player.cs プロジェクト: postcn/Dominion
        /// <summary>
        /// Cards are indexed by position, must be one from every player that had a card in their list.
        /// If their list was empty, pass a null in that spot.
        /// </summary>
        /// <param name="cards"></param>
        /// <returns></returns>
        public StatusObject validateThiefStolenCards(List<Card> cards)
        {
            StatusObject ret = new StatusObject(false);
            this.thiefTrashed = new List<Card>();
            for (int i = 0; i < cards.Count; i++)
            {
                List<Card> stolen = this.thiefList[i];
                if (cards[i] == null && stolen.Count == 0)
                {
                    continue;
                }
                else if (cards[i] == null)
                {
                    ret.setSelectTrashFromThief(true);
                    this.thiefTrashed = new List<Card>();
                    return ret;
                }
                else
                {
                    if (stolen.Contains(cards[i]))
                    {
                        this.thiefTrashed.Add(cards[i]);
                    }
                    else
                    {
                        ret.setSelectTrashFromThief(true);
                        this.thiefTrashed = new List<Card>();
                        return ret;
                    }
                }
            }

            //if it gets here they have selected one card from each list, or there were no money cards in part of the list and null was passed in
            int pos = 0;
            foreach (Card c in this.thiefTrashed)
            {
                List<Card> stolen = this.thiefList[pos];
                while (!stolen.Contains(c))
                {
                    pos++;
                    stolen = this.thiefList[pos];
                }
                stolen.Remove(c);
                foreach (Card cc in this.thiefList[pos])
                {
                    this.otherPlayers[pos].getDeck().discard(cc);
                }
            }
            ret.setKeepTrashedFromThief(true);
            ret.setMessage(Internationalizer.getMessage("ThiefMsg3"));
            return ret;
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: postcn/Dominion
        public StatusObject keepCardsFromThief(List<Card> cards)
        {
            StatusObject ret = new StatusObject(false);
            List<Card> thiefCopy = new List<Card>();
            foreach (Card c in this.thiefTrashed)
            {
                thiefCopy.Add(c);
            }

            foreach (Card c in cards)
            {
                if (!thiefCopy.Remove(c))
                {
                    ret.setKeepTrashedFromThief(true);
                    return ret;
                }
            }

            //gets here all were in the theifTrashedList
            foreach (Card c in cards)
            {
                this.getDeck().discard(c);
            }

            this.thiefTrashed = new List<Card>();
            return ret;
        }