public static void gainCardFeast(Player p, StatusObject o) { p.setGain(true); p.setGainsLeft(p.getGainsLeft() + 1); //You gain a card worth 5 which is 1 more than cost of feast. p.setCurrencyForGain(5); p.getPlayed().Remove(CardMother.Feast()); o.setTrashedCorrectly(true); }
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; }
public static void addNeededTrashes(Player p, StatusObject o) { p.setTrashesNeeded(p.getTrashesNeeded() + 1); p.setTrashCurrencyBonus(3); o.setTrashACopperForCurrency(true); }
public void testMilitiaEffectTooManyCards() { StatusObject o = new StatusObject(false); o.setMilitiaPlayed(true); List<Card> cards = new List<Card>(); cards.Add(CardMother.Copper()); cards.Add(CardMother.Copper()); cards.Add(CardMother.Copper()); o = p.militiaDiscardEffect(cards); Assert.IsTrue(o.wasMilitiaPlayed()); Assert.AreEqual(0, p.getDeck().getInDiscard().Count); }
public void setUp() { this.o = new StatusObject(false); }
public void testThiefActionWithNull() { Game g = new Game(3); g.getPlayers()[1].setDeck(new Deck(new List<Card>())); Player p = g.getCurrentPlayer(); StatusObject o = new StatusObject(false); CardFunctions.thiefAction(p, o); List<List<Card>> thiefed = p.getThiefList(); Assert.AreEqual(0, thiefed[0].Count); }
public void testGainCardRemodel() { StatusObject o = new StatusObject(false); CardFunctions.gainCardRemodel(p, o); Assert.IsTrue(p.getGain()); Assert.IsTrue(o.trashForGainCheck()); Assert.AreEqual(2, p.getCurrencyForGainBonus()); }
public void testGainCardChapel() { StatusObject o = new StatusObject(false); CardFunctions.trashUptoFourCards(p, o); Assert.IsTrue(o.needToTrashCards()); }
/// <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 discardDeck(Boolean discard) { StatusObject retVal = new StatusObject(false); if (discard == false) { retVal.setDeckDiscardedCorrectly(true); return retVal; } int size = this.getDeck().getInDeck().Count; Deck d = this.getDeck(); //put deck into discard for (int i = 0; i < size; i++) { d.getInDiscard().Add(d.getInDeck().ElementAt(0)); d.getInDeck().RemoveAt(0); } retVal.setDeckDiscardedCorrectly(true); return retVal; }
public StatusObject discardCardsAndDrawSameAmount(List<Card> cards) { StatusObject retVal = new StatusObject(false); //check if there are actually no cards in the list. Skip the rest of the code if there aren't any. if (cards.Count == 0) { retVal.setDiscardedAndDrawn(true); return retVal; } StatusObject returner = allCardsInHand(cards, retVal); if (returner != null) { return returner; } //if it gets to here all the cards are in the hand. Proceed to remove them and draw the same number. //now we can modify the player's actual hand Hand h = this.getHand(); Deck d = this.getDeck(); foreach (Card c in cards) { h.discard(c, d); } //now we discarded all of the cards, draw the number that we need CardFunctions.draw(this, cards.Count); retVal.setDiscardedAndDrawn(true); return retVal; }
public StatusObject callDelayedFunctions() { StatusObject stat = new StatusObject(false); while (this.functionsToCall.Count > 0) { DelayedFunction func = this.functionsToCall.Dequeue(); stat = func.performAction(); if (stat.wasMilitiaPlayed()) { break; } } return stat; }
public static void gainCardRemodel(Player p, StatusObject o) { p.setGain(true); p.setGainsLeft(p.getGainsLeft() + 1); p.setCurrencyForGainBonus(2); o.setTrashForGain(true); }
public static void discardDeckChancellor(Player p, StatusObject o) { o.setDiscardDeck(true); }
public static void trashUptoFourCards(Player p, StatusObject o) { o.setTrashCards(true); p.setPossibleTrashes(p.getPossibleTrashes() + 4); }
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 trashForGain(Card c) { StatusObject o = new StatusObject(false); if (this.myHand.getHand().Count == 0) { o.setTrashedCorrectly(true); this.currencyForGainBonus = 0; this.gainsLeft = 0; } if (this.gain) { //check if card is in hand or if its feast (which has already been played) if (this.myHand.contains(c)) { this.myHand.remove(c);//don't put it anywhere so trashed this.currencyForGain = c.getCost() + this.currencyForGainBonus; if (this.gainsLeft <= 0) { this.currencyForGainBonus = 0; } o.setTrashedCorrectly(true); } } return o; }
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; }
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; }
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; }
public void testGainCardMine() { StatusObject o = new StatusObject(false); CardFunctions.mineATreasure(p, o); Assert.IsTrue(o.needToMine()); }
public StatusObject keepOrDiscardSpiedCards(List<Card> discard) { StatusObject o = new StatusObject(false); for (int i = 0; i < discard.Count; i++) { Player p = PlayerGetPlayerInList(i); if (discard[i] != null && !p.getDeck().peekAtTopCard().Equals(discard[i])) { return o; } } for (int i = 0; i < discard.Count; i++) { Player p = PlayerGetPlayerInList(i); if (discard[i] != null && p.getDeck().peekAtTopCard().Equals(discard[i])) { p.getDeck().discard(p.getDeck().draw()); } } o.setSpiedSuccessfully(true); return o; }
public void testGainCardWorkshop() { StatusObject o = new StatusObject(false); CardFunctions.gainCardWorkshop(p, o); Assert.IsTrue(p.getGain()); Assert.IsTrue(o.wasTrashedCorrectly()); Assert.AreEqual(4, p.getCurrencyForGain()); }
/// <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 void testGainCardChancellor() { StatusObject o = new StatusObject(false); CardFunctions.discardDeckChancellor(p, o); Assert.IsTrue(o.needToDisardDeck()); }
public StatusObject mineATreasureCard(Card c) { StatusObject retVal = new StatusObject(false); if (c == null) { return retVal; } if (this.trashesNeeded <= 0 || (!this.myHand.contains(CardMother.Copper()) && !this.myHand.contains(CardMother.Silver()))) { retVal.setMinedCorrectly(true); this.trashesNeeded = 0; return retVal; } if (c.Equals(CardMother.Copper()) || c.Equals(CardMother.Silver())) { if (c.Equals(CardMother.Copper())) { this.getHand().getHand().Remove(c); this.getHand().getHand().Add(CardMother.Silver()); retVal.setMinedCorrectly(true); this.trashesNeeded--; } else { this.getHand().getHand().Remove(c); this.getHand().getHand().Add(CardMother.Gold()); retVal.setMinedCorrectly(true); this.trashesNeeded--; } if (this.trashesNeeded > 0) { retVal.setMinedCorrectly(false); retVal.setMineTreasure(true); } return retVal; } else { return retVal; } }
public void testMilitiaEffectLessThanThreeInHand() { StatusObject o = new StatusObject(false); o.setMilitiaPlayed(true); p.getHand().remove(CardMother.Copper()); p.getHand().remove(CardMother.Copper()); o = p.militiaDiscardEffect(new List<Card>()); Assert.IsFalse(o.wasMilitiaPlayed()); Assert.AreEqual(0, p.getDeck().getInDiscard().Count); }
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; }
//Passing in null counts as it being false, don't want to trash because they have the option public StatusObject trashACopperForCurrencyBonus(Card aCard) { StatusObject retVal = new StatusObject(false); if (this.trashesNeeded <= 0 || !this.myHand.contains(CardMother.Copper())) { this.trashesNeeded = 0; retVal.setCopperTrashedForCurrency(true); return retVal; } if (aCard == null) { retVal.setCopperTrashedForCurrency(true); return retVal; } if (!aCard.Equals(CardMother.Copper())) { return retVal; } if (!this.getHand().contains(aCard)) { return retVal; } this.getHand().remove(aCard); this.bonusCurrencyForBuy += this.trashCurrencyBonus; this.trashesNeeded--; if (trashesNeeded == 0) { retVal.setCopperTrashedForCurrency(true); } else { retVal.setTrashACopperForCurrency(true); } return retVal; }
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); } }