예제 #1
0
 public StatusObject performAction()
 {
     StatusObject retVal = new StatusObject(false);
     switch (this.funcNum)
     {
         case 0: //draw a card
             CardFunctions.draw(p, 1);
             break;
         case 1: //Militia
             retVal.setMilitiaPlayed(true);
             retVal.setContinueWithDelayedFunctions(true);
             retVal.setMessage(Internationalizer.getMessage("NeedMilitia"));
             break;
     }
     return retVal;
 }
예제 #2
0
파일: Player.cs 프로젝트: postcn/Dominion
        /// <summary>
        /// The trashing effect for the militia card. Needs the lastObject so we know whether to continue with more functions or not afterwards
        /// in the delayed function calls.
        /// </summary>
        /// <param name="cards"></param>
        /// <param name="lastObject"></param>
        /// <returns></returns>
        public StatusObject militiaDiscardEffect(List<Card> cards)
        {
            StatusObject lastObject = new StatusObject(false);
            lastObject.setMilitiaPlayed(true);
            lastObject.setContinueWithDelayedFunctions(true);
            if (this.myHand.size() <= 3)
            {
                lastObject.setMilitiaPlayed(false);
                return lastObject;
            }
            List<Card> handCopy = new List<Card>();
            foreach (Card c in this.myHand.getHand())
            {
                handCopy.Add(c);
            }

            foreach (Card c in cards)
            {
                if (!handCopy.Remove(c))
                {
                    lastObject.setMessage(Internationalizer.getMessage("MissingCards1") + c.getName() + Internationalizer.getMessage("MissingCards2"));
                    return lastObject;
                }
            }

            if (handCopy.Count != 3)
            {
                lastObject.setMessage(Internationalizer.getMessage("IncorrectForMilitia"));
                return lastObject;
            }

            //All the cards were in the hand and there were the correct number
            foreach (Card c in cards)
            {
                this.myHand.discard(c, this.myDeck);
            }
            lastObject.setMilitiaPlayed(false);//no longer need the militia action.
            return lastObject;
        }