diff --git a/.gitattributes b/.gitattributes index 1185571c4f9..b94777b3b7b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1667,6 +1667,7 @@ forge-gui/res/cardsfolder/c/call_to_the_kindred.txt -text forge-gui/res/cardsfolder/c/call_to_the_netherworld.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/caller_of_gales.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/caller_of_the_claw.txt svneol=native#text/plain +forge-gui/res/cardsfolder/c/caller_of_the_hunt.txt -text forge-gui/res/cardsfolder/c/callous_deceiver.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/callous_giant.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/callous_oppressor.txt -text @@ -14983,6 +14984,7 @@ forge-gui/src/main/java/forge/game/combat/CombatLki.java -text forge-gui/src/main/java/forge/game/combat/CombatUtil.java svneol=native#text/plain forge-gui/src/main/java/forge/game/cost/Cost.java svneol=native#text/plain forge-gui/src/main/java/forge/game/cost/CostAddMana.java -text +forge-gui/src/main/java/forge/game/cost/CostChooseCreatureType.java -text forge-gui/src/main/java/forge/game/cost/CostDamage.java -text forge-gui/src/main/java/forge/game/cost/CostDiscard.java -text forge-gui/src/main/java/forge/game/cost/CostDraw.java -text diff --git a/forge-gui/res/cardsfolder/c/caller_of_the_hunt.txt b/forge-gui/res/cardsfolder/c/caller_of_the_hunt.txt new file mode 100644 index 00000000000..3d0065ece8f --- /dev/null +++ b/forge-gui/res/cardsfolder/c/caller_of_the_hunt.txt @@ -0,0 +1,10 @@ +Name:Caller of the Hunt +ManaCost:2 G +Types:Creature Human +PT:*/* +Text:As an additional cost to cast CARDNAME, choose a creature type. +S:Mode$ Continuous | EffectZone$ All | CharacteristicDefining$ True | SetPower$ X | SetToughness$ X | Description$ CARDNAME's power and toughness are each equal to the number of creatures of the chosen type on the battlefield. +SVar:X:Count$Valid Creature.ChosenType +A:SP$ PermanentCreature | Cost$ 2 G ChooseCreatureType<1> | AILogic$ MostProminentOnBattlefield +SVar:Picture:http://www.wizards.com/global/images/magic/general/caller_of_the_hunt.jpg +Oracle:As an additional cost to cast Caller of the Hunt, choose a creature type.\nCaller of the Hunt's power and toughness are each equal to the number of creatures of the chosen type on the battlefield. diff --git a/forge-gui/src/main/java/forge/game/cost/Cost.java b/forge-gui/src/main/java/forge/game/cost/Cost.java index cfdea5bdf17..518e6b75996 100644 --- a/forge-gui/src/main/java/forge/game/cost/Cost.java +++ b/forge-gui/src/main/java/forge/game/cost/Cost.java @@ -243,6 +243,11 @@ public class Cost { return new CostUnattach(splitStr[0], description); } + if (parse.startsWith("ChooseCreatureType<")) { + final String[] splitStr = abCostParse(parse, 1); + return new CostChooseCreatureType(splitStr[0]); + } + if (parse.startsWith("DamageYou<")) { // Damage final String[] splitStr = abCostParse(parse, 1); diff --git a/forge-gui/src/main/java/forge/game/cost/CostChooseCreatureType.java b/forge-gui/src/main/java/forge/game/cost/CostChooseCreatureType.java new file mode 100644 index 00000000000..599d2abf722 --- /dev/null +++ b/forge-gui/src/main/java/forge/game/cost/CostChooseCreatureType.java @@ -0,0 +1,122 @@ +/* + * Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package forge.game.cost; + +import java.util.ArrayList; +import forge.card.CardType; +import forge.game.Game; +import forge.game.ability.AbilityUtils; +import forge.game.card.Card; +import forge.game.player.Player; +import forge.game.spellability.SpellAbility; +import forge.gui.GuiDialog; + +/** + * The Class CostChooseCreatureType. + */ +public class CostChooseCreatureType extends CostPart { + + /** + * Instantiates a new cost mill. + * + * @param amount + * the amount + */ + public CostChooseCreatureType(final String amount) { + this.setAmount(amount); + } + + /* + * (non-Javadoc) + * + * @see + * forge.card.cost.CostPart#canPay(forge.card.spellability.SpellAbility, + * forge.Card, forge.Player, forge.card.cost.Cost) + */ + @Override + public final boolean canPay(final SpellAbility ability) { + return true; + } + + /* + * (non-Javadoc) + * + * @see + * forge.card.cost.CostPart#payHuman(forge.card.spellability.SpellAbility, + * forge.Card, forge.card.cost.Cost_Payment) + */ + @Override + public final boolean payHuman(final SpellAbility ability, final Game game) { + final Player activator = ability.getActivatingPlayer(); + final Card source = ability.getSourceCard(); + + final StringBuilder sb = new StringBuilder(); + sb.append(source.getName()).append(" - Choose a creature type?"); + + if (GuiDialog.confirm(source, sb.toString())) { + String choice = activator.getController().chooseSomeType("Creature", ability, new ArrayList(CardType.getCreatureTypes()), new ArrayList()); + source.setChosenType(choice); + } else { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see forge.card.cost.CostPart#toString() + */ + @Override + public final String toString() { + final StringBuilder sb = new StringBuilder(); + final Integer i = this.convertAmount(); + sb.append("Choose "); + sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), "creature type")); + return sb.toString(); + } + + + /* (non-Javadoc) + * @see forge.card.cost.CostPart#decideAIPayment(forge.game.player.AIPlayer, forge.card.spellability.SpellAbility, forge.Card) + */ + @Override + public PaymentDecision decideAIPayment(Player ai, SpellAbility ability, Card source) { + Integer c = this.convertAmount(); + + if (c == null) { + final String sVar = ability.getSVar(this.getAmount()); + // Generalize this + if (sVar.equals("XChoice")) { + return null; // cannot pay + } else { + c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); + } + } + return new PaymentDecision(c); + } + + @Override + public boolean payAI(PaymentDecision decision, Player ai, + SpellAbility ability, Card source) { + String choice = ai.getController().chooseSomeType("Creature", ability, new ArrayList(CardType.getCreatureTypes()), new ArrayList()); + source.setChosenType(choice); + return true; + } + +}