From 619b4ce3fa88a260ab0e9699f82a95dd590b3969 Mon Sep 17 00:00:00 2001 From: Sol Date: Sat, 24 Sep 2016 14:01:08 +0000 Subject: [PATCH] - Adding second ability for Animation Module, marking it not for AI since PutCounters needs AI for new mode AND chooseCounters needs some AI depending on the target. --- .../ability/effects/CountersPutEffect.java | 54 ++++++++++++++++--- .../res/cardsfolder/a/animation_module.txt | 2 + 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java index 1a4a2346245..d4532784e69 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java @@ -18,6 +18,7 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -29,7 +30,7 @@ public class CountersPutEffect extends SpellAbilityEffect { final Card card = sa.getHostCard(); final boolean dividedAsYouChoose = sa.hasParam("DividedAsYouChoose"); - final CounterType cType = CounterType.valueOf(sa.getParam("CounterType")); + final int amount = AbilityUtils.calculateAmount(card, sa.getParam("CounterNum"), sa); if (sa.hasParam("Bolster")) { sb.append("Bolster ").append(amount); @@ -43,7 +44,16 @@ public class CountersPutEffect extends SpellAbilityEffect { if (sa.hasParam("UpTo")) { sb.append("up to "); } - sb.append(amount).append(" ").append(cType.getName()).append(" counter"); + + sb.append(amount).append(" "); + + String type = sa.getParam("CounterType"); + if (type.equals("ExistingCounter")) { + sb.append("of an existing counter"); + } else { + + sb.append( CounterType.valueOf(type).getName()).append(" counter"); + } if (amount != 1) { sb.append("s"); } @@ -77,13 +87,17 @@ public class CountersPutEffect extends SpellAbilityEffect { final Card card = sa.getHostCard(); final Player activator = sa.getActivatingPlayer(); - CounterType counterType; + String strTyp = sa.getParam("CounterType"); + CounterType counterType = null; + boolean existingCounter = strTyp.equals("ExistingCounter"); - try { - counterType = AbilityUtils.getCounterType(sa.getParam("CounterType"), sa); - } catch (Exception e) { - System.out.println("Counter type doesn't match, nor does an SVar exist with the type name."); - return; + if (!existingCounter) { + try { + counterType = AbilityUtils.getCounterType(strTyp, sa); + } catch (Exception e) { + System.out.println("Counter type doesn't match, nor does an SVar exist with the type name."); + return; + } } final boolean etbcounter = sa.hasParam("ETB"); @@ -108,6 +122,30 @@ public class CountersPutEffect extends SpellAbilityEffect { } for (final GameObject obj : tgtObjects) { + if (existingCounter) { + final List choices = new ArrayList(); + if (obj instanceof Card) { + for (final CounterType ct : ((Card) obj).getCounters().keySet()) { + if (((Card) obj).getCounters(ct) > 0) { + choices.add(ct); + } + } + } + else if (obj instanceof Player) { + for (final CounterType ct : ((Player) obj).getCounters().keySet()) { + if (((Player) obj).getCounters(ct) > 0) { + choices.add(ct); + } + } + } + + if (choices.isEmpty()) { + continue; + } + counterType = choices.size() == 1 ? choices.get(0) : activator.getController().chooseCounterType(choices, sa, "Select counter type to add"); + } + + if (obj instanceof Card) { Card tgtCard = (Card) obj; counterAmount = sa.usesTargeting() && sa.hasParam("DividedAsYouChoose") ? sa.getTargetRestrictions().getDividedValue(tgtCard) : counterAmount; diff --git a/forge-gui/res/cardsfolder/a/animation_module.txt b/forge-gui/res/cardsfolder/a/animation_module.txt index 5bc7c85b3ad..394f22a32af 100644 --- a/forge-gui/res/cardsfolder/a/animation_module.txt +++ b/forge-gui/res/cardsfolder/a/animation_module.txt @@ -3,6 +3,8 @@ ManaCost:1 Types:Artifact T:Mode$ CounterAddedOnce | ValidCard$ Permanent.YouCtrl | TriggerZones$ Battlefield | CounterType$ P1P1 | Execute$ TrigToken | TriggerDescription$ Whenever one or more +1/+1 counters are placed on a permanent you control, you may pay {1}. If you do, create a 1/1 colorless Servo artifact creature token. SVar:TrigToken:AB$ Token | Cost$ 1 | TokenAmount$ 1 | TokenName$ Servo | TokenTypes$ Artifact,Creature,Servo | TokenOwner$ You | TokenColors$ Colorless | TokenPower$ 1 | TokenToughness$ 1 | TokenImage$ c 1 1 servo | TokenAltImages$ c_1_1_servo2,c_1_1_servo3 +A:AB$ PutCounter | Cost$ 3 T | ValidTgts$ Permanent,Player | TgtPrompt$ Select target player or permanent | CounterType$ ExistingCounter | CounterNum$ 1 | SpellDescription$ Choose a counter on target permanent or player. Give that permanent or player another counter of that kind. DeckHints:Ability$Counters +SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/animation_module.jpg Oracle:Whenever one or more +1/+1 counters are placed on a permanent you control, you may pay {1}. If you do, create a 1/1 colorless Servo artifact creature token.\n{3}, {T}: Choose a counter on target permanent or player. Give that permanent or player another counter of that kind.