From 9a13f34517ddaeedb66afd830d1e9c4306db3b8b Mon Sep 17 00:00:00 2001 From: swordshine Date: Mon, 1 Apr 2013 02:23:14 +0000 Subject: [PATCH] - Added Leech Bonder --- .gitattributes | 1 + res/cardsfolder/l/leech_bonder.txt | 11 +++ .../ability/effects/CountersMoveEffect.java | 99 +++++++++++++++++-- 3 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 res/cardsfolder/l/leech_bonder.txt diff --git a/.gitattributes b/.gitattributes index 7f59769cb7c..16003e58249 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5953,6 +5953,7 @@ res/cardsfolder/l/leap_of_flame.txt svneol=native#text/plain res/cardsfolder/l/leaping_lizard.txt svneol=native#text/plain res/cardsfolder/l/leatherback_baloth.txt svneol=native#text/plain res/cardsfolder/l/leave_no_trace.txt svneol=native#text/plain +res/cardsfolder/l/leech_bonder.txt -text res/cardsfolder/l/leeches.txt svneol=native#text/plain res/cardsfolder/l/leeching_bite.txt -text res/cardsfolder/l/leeching_licid.txt -text diff --git a/res/cardsfolder/l/leech_bonder.txt b/res/cardsfolder/l/leech_bonder.txt new file mode 100644 index 00000000000..a7f0e03063e --- /dev/null +++ b/res/cardsfolder/l/leech_bonder.txt @@ -0,0 +1,11 @@ +Name:Leech Bonder +ManaCost:2 U +Types:Creature Merfolk Soldier +PT:3/3 +K:etbCounter:M1M1:2 +A:AB$ Pump | Cost$ U Q | ValidTgts$ Creature | TgtPrompt$ Select target creature to remove counters | SubAbility$ DBMove | StackDescription$ None | SpellDescription$ Move a counter from target creature onto another target creature. +SVar:DBMove:DB$ MoveCounter | Source$ ParentTarget | ValidTgts$ Creature | TgtPrompt$ Select target creature to add counters | TargetUnique$ True | CounterType$ Any | CounterNum$ 1 +SVar:RemAIDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/leech_bonder.jpg +Oracle:Leech Bonder enters the battlefield with two -1/-1 counters on it.\n{U}, {Q}: Move a counter from target creature onto another target creature. ({Q} is the untap symbol.) +SetInfo:SHM Uncommon \ No newline at end of file diff --git a/src/main/java/forge/card/ability/effects/CountersMoveEffect.java b/src/main/java/forge/card/ability/effects/CountersMoveEffect.java index e2cba82325b..dd41e4f22cc 100644 --- a/src/main/java/forge/card/ability/effects/CountersMoveEffect.java +++ b/src/main/java/forge/card/ability/effects/CountersMoveEffect.java @@ -1,6 +1,8 @@ package forge.card.ability.effects; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import forge.Card; import forge.CounterType; @@ -8,6 +10,7 @@ import forge.card.ability.AbilityUtils; import forge.card.ability.SpellAbilityEffect; import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; +import forge.gui.GuiChoose; public class CountersMoveEffect extends SpellAbilityEffect { @@ -28,11 +31,19 @@ public class CountersMoveEffect extends SpellAbilityEffect { source = srcCards.get(0); } final List tgtCards = getTargetCards(sa); - - final CounterType cType = CounterType.valueOf(sa.getParam("CounterType")); + final String countername = sa.getParam("CounterType"); final int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa); - sb.append("Move ").append(amount).append(" ").append(cType.getName()).append(" counter"); + sb.append("Move "); + if ("Any".matches(countername)) { + if (amount == 1) { + sb.append("a counter"); + } else { + sb.append(amount).append(" ").append(" counter"); + } + } else { + sb.append(amount).append(" ").append(countername).append(" counter"); + } if (amount != 1) { sb.append("s"); } @@ -46,12 +57,21 @@ public class CountersMoveEffect extends SpellAbilityEffect { @Override public void resolve(SpellAbility sa) { final Card host = sa.getSourceCard(); - - final CounterType cType = CounterType.valueOf(sa.getParam("CounterType")); + final String counterName = sa.getParam("CounterType"); int amount = 0; if (!sa.getParam("CounterNum").equals("All")) { amount = AbilityUtils.calculateAmount(host, sa.getParam("CounterNum"), sa); } + + CounterType cType = null; + try { + cType = AbilityUtils.getCounterType(counterName, sa); + } catch (Exception e) { + if (!counterName.matches("Any")) { + System.out.println("Counter type doesn't match, nor does an SVar exist with the type name."); + return; + } + } Card source = null; List srcCards; @@ -76,16 +96,75 @@ public class CountersMoveEffect extends SpellAbilityEffect { for (final Card dest : tgtCards) { if ((null != source) && (null != dest)) { - if (source.getCounters(cType) >= amount) { - if (!dest.hasKeyword("CARDNAME can't have counters placed on it.") - && !(dest.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && cType - .equals(CounterType.M1M1))) { + if (!"Any".matches(counterName)) { + if (dest.canHaveCountersPlacedOnIt(cType) + && source.getCounters(cType) >= amount) { dest.addCounter(cType, amount, true); source.subtractCounter(cType, amount); } + } else { + if (dest.hasKeyword("CARDNAME can't have counters placed on it.")) { + return; + } + boolean check = false; + for (final Card c : dest.getController().getCreaturesInPlay()) {//Melira, Sylvok Outcast + if (c.hasKeyword("Creatures you control can't have -1/-1 counters placed on them.")) { + check = true; + } + } + while (amount > 0 && source.hasCounters()) { + final Map tgtCounters = source.getCounters(); + CounterType chosenType = null; + int chosenAmount; + if (sa.getActivatingPlayer().isHuman()) { + final ArrayList typeChoices = new ArrayList(); + // get types of counters + for (CounterType key : tgtCounters.keySet()) { + if (tgtCounters.get(key) > 0 && !(key == CounterType.M1M1 && check)) { + typeChoices.add(key); + } + } + if (typeChoices.isEmpty()) { + return; + } + if (typeChoices.size() > 1) { + String prompt = "Select type counters to remove"; + chosenType = GuiChoose.one(prompt, typeChoices); + } else { + chosenType = typeChoices.get(0); + } + chosenAmount = tgtCounters.get(chosenType); + if (chosenAmount > amount) { + chosenAmount = amount; + } + // make list of amount choices + if (chosenAmount > 1) { + final List choices = new ArrayList(); + for (int i = 1; i <= chosenAmount; i++) { + choices.add(Integer.valueOf(i)); + } + String prompt = "Select the number of " + chosenType.getName() + " counters to remove"; + chosenAmount = GuiChoose.one(prompt, choices); + } + } else { + for (Object key : tgtCounters.keySet()) { + if (tgtCounters.get(key) > 0) { + chosenType = (CounterType) key; + break; + } + } + // subtract all of selected type + chosenAmount = tgtCounters.get(chosenType); + if (chosenAmount > amount) { + chosenAmount = amount; + } + } + dest.addCounter(chosenType, chosenAmount, true); + source.subtractCounter(chosenType, chosenAmount); + amount -= chosenAmount; + } } } } } // moveCounterResolve - }