diff --git a/.gitattributes b/.gitattributes index 5479fb7e5d8..b6b9f0e803e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4818,6 +4818,7 @@ res/cardsfolder/h/hand_of_justice.txt svneol=native#text/plain res/cardsfolder/h/hand_of_the_praetors.txt svneol=native#text/plain res/cardsfolder/h/hand_to_hand.txt -text res/cardsfolder/h/hands_of_binding.txt -text +res/cardsfolder/h/hankyu.txt -text res/cardsfolder/h/hanna.txt -text res/cardsfolder/h/hanna_ships_navigator.txt svneol=native#text/plain res/cardsfolder/h/hannas_custody.txt svneol=native#text/plain diff --git a/res/cardsfolder/h/hankyu.txt b/res/cardsfolder/h/hankyu.txt new file mode 100644 index 00000000000..cfd55ea6978 --- /dev/null +++ b/res/cardsfolder/h/hankyu.txt @@ -0,0 +1,11 @@ +Name:Hankyu +ManaCost:1 +Types:Artifact Equipment +K:Equip 4 +S:Mode$ Continuous | Affected$ Card.EquippedBy | AddAbility$ HankyuPutCounter & HankyuDmg | AddSVar$ HankyuX | Description$ Equipped creature has "Tap: Put an aim counter on CARDNAME" and "Tap, Remove all aim counters from CARDNAME: This creature deals damage to target creature or player equal to the number of aim counters removed this way." +SVar:HankyuPutCounter:AB$ PutCounter | Cost$ T | CounterType$ AIM | CounterNum$ 1 | Defined$ OriginalHost | SpellDescription$ Put an aim counter on Hankyu. +SVar:HankyuDmg:AB$ DealDamage | Cost$ T SubCounter | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | NumDmg$ HankyuX | References$ HankyuX | SpellDescription$ CARDNAME deals damage to target creature or player equal to the number of aim counters removed this way. +SVar:HankyuX:SVar$CostCountersRemoved +SVar:RemAIDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/hankyu.jpg +Oracle:Equipped creature has "{T}: Put an aim counter on Hankyu" and "{T}, Remove all aim counters from Hankyu: This creature deals damage to target creature or player equal to the number of aim counters removed this way."\nEquip {4} ({4}: Attach to target creature you control. Equip only as a sorcery.) diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index d0bec09f306..d7df86f7497 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -22,6 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.common.collect.Lists; + import forge.Card; import forge.CardLists; import forge.CounterType; @@ -51,11 +53,11 @@ public class CostRemoveCounter extends CostPartWithList { */ public static final class InputSelectCardToRemoveCounter extends InputSelectCards { private static final long serialVersionUID = 2685832214519141903L; - + private final Map cardsChosen; private final CounterType counterType; private final List validChoices; - + public InputSelectCardToRemoveCounter(int cntCounters, CounterType cType, List validCards) { super(cntCounters, cntCounters); this.validChoices = validCards; @@ -74,22 +76,22 @@ public class CostRemoveCounter extends CostPartWithList { selected.add(c); else cardsChosen.put(c, tc+1); - + onSelectStateChanged(c, true); return true; } - + @Override protected boolean hasEnoughTargets() { return hasAllTargets(); } - + @Override protected boolean hasAllTargets() { int sum = getDistibutedCounters(); return sum >= max; } - + protected String getMessage() { return max == Integer.MAX_VALUE ? String.format(message, getDistibutedCounters()) @@ -119,7 +121,9 @@ public class CostRemoveCounter extends CostPartWithList { final String amount = this.getAmount(); final Card source = ability.getSourceCard(); Integer c = this.convertAmount(); - + final String type = this.getType(); + final Player activator = ability.getActivatingPlayer(); + String sVarAmount = ability.getSVar(amount); cntRemoved = 1; if (c != null) @@ -142,10 +146,20 @@ public class CostRemoveCounter extends CostPartWithList { source.setSVar("CostCountersRemoved", Integer.toString(cntRemoved)); executePayment(ability, source); return true; + } else if (type.equals("OriginalHost")) { + int maxCounters = ability.getOriginalHost().getCounters(this.counter); + if (amount.equals("All")) { + cntRemoved = maxCounters; + } + if (maxCounters < cntRemoved) + return false; + cntRemoved = cntRemoved >= 0 ? cntRemoved : maxCounters; + source.setSVar("CostCountersRemoved", Integer.toString(cntRemoved)); + executePayment(ability, ability.getOriginalHost()); + return true; } - - List validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(getZone()), getType().split(";"), ability.getActivatingPlayer(), source); + List validCards = CardLists.getValidCards(activator.getCardsIn(getZone()), type.split(";"), activator, source); if (this.getZone().equals(ZoneType.Battlefield)) { final InputSelectCardToRemoveCounter inp = new InputSelectCardToRemoveCounter(cntRemoved, getCounter(), validCards); inp.setMessage("Remove %d " + getCounter().getName() + " counters from " + getDescriptiveType()); @@ -170,7 +184,7 @@ public class CostRemoveCounter extends CostPartWithList { return executePayment(ability, inp.getSelected()); } - + // Rift Elemental only - always removes 1 counter, so there will be no code for N counters. List suspended = new ArrayList(); for(Card crd : validCards) @@ -291,6 +305,7 @@ public class CostRemoveCounter extends CostPartWithList { final CounterType cntrs = this.getCounter(); final Player activator = ability.getActivatingPlayer(); final Card source = ability.getSourceCard(); + final String type = this.getType(); final Integer amount = this.convertAmount(); if (this.payCostFromSource()) { @@ -299,7 +314,12 @@ public class CostRemoveCounter extends CostPartWithList { } } else { - final List typeList = CardLists.getValidCards(activator.getCardsIn(this.getZone()), this.getType().split(";"), activator, source); + List typeList; + if (type.equals("OriginalHost")) { + typeList = Lists.newArrayList(ability.getOriginalHost()); + } else { + typeList = CardLists.getValidCards(activator.getCardsIn(this.getZone()), type.split(";"), activator, source); + } if (amount != null) { for (Card c : typeList) { if (c.getCounters(cntrs) - amount >= 0) { @@ -343,7 +363,7 @@ public class CostRemoveCounter extends CostPartWithList { protected void doPayment(SpellAbility ability, Card targetCard){ targetCard.subtractCounter(this.getCounter(), cntRemoved); } - + /* (non-Javadoc) * @see forge.card.cost.CostPartWithList#getHashForList() */ @@ -359,8 +379,8 @@ public class CostRemoveCounter extends CostPartWithList { public PaymentDecision decideAIPayment(Player ai, SpellAbility ability, Card source) { final String amount = this.getAmount(); Integer c = this.convertAmount(); - - + final String type = this.getType(); + if (c == null) { final String sVar = ability.getSVar(amount); if (sVar.equals("XChoice")) { @@ -372,18 +392,22 @@ public class CostRemoveCounter extends CostPartWithList { c = AbilityUtils.calculateAmount(source, amount, ability); } } - + if (!this.payCostFromSource()) { - final List typeList = - CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source); + List typeList; + if (type.equals("OriginalHost")) { + typeList = Lists.newArrayList(ability.getOriginalHost()); + } else { + typeList = CardLists.getValidCards(ai.getCardsIn(this.getZone()), type.split(";"), ai, source); + } for (Card card : typeList) { if (card.getCounters(this.getCounter()) >= c) { return new PaymentDecision(card); } } return null; - } - + } + if (c > source.getCounters(this.getCounter())) { System.out.println("Not enough " + this.counter + " on " + source.getName()); return null; diff --git a/src/main/java/forge/card/staticability/StaticAbilityContinuous.java b/src/main/java/forge/card/staticability/StaticAbilityContinuous.java index dd43daf9acd..a3ecefc9f03 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityContinuous.java +++ b/src/main/java/forge/card/staticability/StaticAbilityContinuous.java @@ -384,7 +384,7 @@ public class StaticAbilityContinuous { for (final String sVar : addSVars) { String actualSVar = hostCard.getSVar(sVar); String name = sVar; - if (actualSVar.startsWith("SVar")) { + if (actualSVar.startsWith("SVar:")) { actualSVar = actualSVar.split("SVar:")[1]; name = actualSVar.split(":")[0]; actualSVar = actualSVar.split(":")[1];