Exemple #1
0
        /// <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;
        }
Exemple #2
0
 public static void thiefAction(Player p, StatusObject o)
 {
     p.clearThiefList();
     p.setOtherPlayerList();
     o.setSelectTrashFromThief(true);
     foreach (Player other in p.getOtherPlayers())
     {
         List<Card> cards = new List<Card>();
         if (!other.getHand().hasDefenseCard())
         {
             for (int i = 0; i < 2; i++)
             {
                 Card c = other.getDeck().draw();
                 if (c == null)
                 {
                     continue;
                 }
                 else if (c.getType() == 1)
                 {
                     cards.Add(c);
                 }
                 else
                 {
                     other.getDeck().discard(c);
                 }
                 p.getGame().addToGameMessage(other.getName() + Internationalizer.getMessage("ThiefMsg1") + c.getName() + Internationalizer.getMessage("ThiefMsg2"));
             }
         }
         else
         {
             p.getGame().addToGameMessage(other.getName() + Internationalizer.getMessage("Defended"));
         }
         p.getThiefList().Add(cards);
     }
 }