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; }
private StatusObject allCardsInHand(List<Card> cards, StatusObject retVal) { List<Card> handCopy = new List<Card>(); //make a copy of the hand so that we can check if all the cards in the list are in the hand foreach (Card c in this.getHand().getHand()) { handCopy.Add(c); } foreach (Card c in cards) { if (!handCopy.Remove(c)) { retVal.setMessage(Internationalizer.getMessage("MissingCards1") + c.getName() + Internationalizer.getMessage("MissingCards2")); return retVal; } } return null; }
/// <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; }
public StatusObject trashCards(List<Card> cards) { StatusObject retVal = new StatusObject(false); //If none then didnt want to discard any if (cards.Count == 0) { retVal.setTrashedCorrectly(true); return retVal; } if (cards.Count > this.possibleTrashes) { retVal.setMessage(Internationalizer.getMessage("MoreThanFour")); return retVal; } StatusObject returner = allCardsInHand(cards, retVal); if (returner != null) { return returner; } //Trash cards foreach (Card c in cards) { this.getHand().remove(c);//trash not discard for the chapel } this.possibleTrashes = 0; retVal.setTrashedCorrectly(true); return retVal; }
public StatusObject play(Card aCard) { StatusObject retVal = new StatusObject(false); if (this.myHand.contains(aCard) && aCard.getPlayable() && this.actionsLeft > 0) { this.actionsLeft--; this.played.Add(this.myHand.remove(aCard)); this.timesToPlayLeft = this.timesToPlayNextCard; this.timesPlayed.Add(this.timesToPlayLeft); this.timesToPlayNextCard = 1; // we just set it to use up those plays. this.lastPlayedCard = aCard; if (this.game != null) { this.game.addToGameMessage(this.name + Internationalizer.getMessage("Played") + aCard.getName()); } if (timesToPlayLeft > 1) { this.playMultipleTimes = false; } while (this.timesToPlayLeft > 0) { this.timesToPlayLeft--; switch (aCard.getFunctionNumber()) { case 0: //No Action break; case 1: //Draw only retVal.setMessage(Internationalizer.getMessage("DrawMsg")); CardFunctions.draw(this, aCard.getAdditionalDraws()); break; case 2: //Draw and Add Actions. retVal.setMessage(Internationalizer.getMessage("DrawActionMsg")); CardFunctions.draw(this, aCard.getAdditionalDraws()); CardFunctions.actionAdd(this, aCard.getActions()); break; case 3: //Draw and Add and Buy retVal.setMessage(Internationalizer.getMessage("DrawActionBuyMsg")); CardFunctions.draw(this, aCard.getAdditionalDraws()); CardFunctions.actionAdd(this, aCard.getActions()); CardFunctions.buyAdd(this, aCard.getBuy()); break; case 4: //Add buy retVal.setMessage(Internationalizer.getMessage("BuyMsg")); CardFunctions.buyAdd(this, aCard.getBuy()); break; case 5: //Add actions and draw retVal.setMessage(Internationalizer.getMessage("DrawActionMsg")); CardFunctions.draw(this, aCard.getAdditionalDraws()); CardFunctions.actionAdd(this, aCard.getActions()); break; case 6: //Add actions and buy retVal.setMessage(Internationalizer.getMessage("ActionBuyMsg")); CardFunctions.actionAdd(this, aCard.getActions()); CardFunctions.buyAdd(this, aCard.getBuy()); break; case 7: //add cards and gain curses. retVal.setMessage(Internationalizer.getMessage("WitchMsg")); CardFunctions.draw(this, aCard.getAdditionalDraws()); CardFunctions.gainCurses(this); break; case 8: //Remodel a card, trash and gain retVal.setMessage(Internationalizer.getMessage("RemodelMsg")); CardFunctions.gainCardRemodel(this, retVal); break; case 9: //Feast, trash and gain retVal.setMessage(Internationalizer.getMessage("FeastMsg")); CardFunctions.gainCardFeast(this, retVal); break; case 10: //Workshop, gain card worth 4 retVal.setMessage(Internationalizer.getMessage("WorkshopMsg")); CardFunctions.gainCardWorkshop(this, retVal); break; case 11: //Throne Room. Double the number of next plays. retVal.setMessage(Internationalizer.getMessage("ThroneRoomMsg")); CardFunctions.doubleNextPlay(this, this.timesToPlayLeft + 1); this.timesToPlayLeft = 0; CardFunctions.actionAdd(this, aCard.getActions()); break; case 12: //Cellar retVal.setMessage(Internationalizer.getMessage("CellarMsg")); CardFunctions.actionAdd(this, aCard.getActions()); CardFunctions.setupDiscardCardsToDrawSameNumber(this, retVal); break; case 13: //MoneyLender retVal.setMessage(Internationalizer.getMessage("MoneylenderMsg")); CardFunctions.addNeededTrashes(this, retVal); break; case 14: //Chapel retVal.setMessage(Internationalizer.getMessage("ChapelMsg")); CardFunctions.trashUptoFourCards(this, retVal); break; case 15: //Chancellor retVal.setMessage(Internationalizer.getMessage("ChancellorMsg")); CardFunctions.discardDeckChancellor(this, retVal); break; case 16: //Militia retVal.setMessage(Internationalizer.getMessage("MilitiaMsg")); if (this.timesToPlayLeft == 0) { CardFunctions.militiaAction(this); } break; case 17: //Bureaucrat retVal.setMessage(Internationalizer.getMessage("BureaucratMsg3")); CardFunctions.bureaucratAction(this); break; case 18: //Mine retVal.setMessage(Internationalizer.getMessage("MineMsg")); CardFunctions.mineATreasure(this, retVal); break; case 19: //Council Room; retVal.setMessage(Internationalizer.getMessage("CouncilRoomMsg")); CardFunctions.councilRoomAction(this); CardFunctions.draw(this, aCard.getAdditionalDraws()); CardFunctions.buyAdd(this, aCard.getBuy()); break; case 20: //Spy; retVal.setMessage(Internationalizer.getMessage("SpyMsg")); CardFunctions.spyFunction(this, retVal); CardFunctions.draw(this, 1); CardFunctions.actionAdd(this, 1); break; case 21: //Thief retVal.setMessage(Internationalizer.getMessage("ThiefMsg")); CardFunctions.thiefAction(this, retVal); break; } } retVal.setPlayed(true); } return retVal; }
/// <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; }
public StatusObject gainCard(CardStack cs) { StatusObject o = new StatusObject(false); if (cs.isEmpty()) { o.setMessage(Internationalizer.getMessage("StackEmpty")); return o; } if (!this.gain) { o.setMessage(Internationalizer.getMessage("NotGain")); return o; } if (this.gainsLeft <= 0) { o.setMessage(Internationalizer.getMessage("NoGainsLeft")); return o; } if (this.currencyForGain >= cs.getCard().getCost()) { this.getDeck().discard(cs.buyOne()); this.gainsLeft--; if (this.gainsLeft == 0) { this.currencyForGain = 0; this.gain = false; } else { if (this.lastPlayedCard.Equals(CardMother.Remodel())) { o.setMessage(Internationalizer.getMessage("WasRemodel")); o.setTrashForGain(true); } else { o.setMessage(Internationalizer.getMessage("GainsLeft")); o.setTrashedCorrectly(true); } } o.setGainedProperly(true); } else { o.setMessage(Internationalizer.getMessage("NotEnoughCur") + this.currencyForGain); } return o; }