From 30f85737c821adedf738e4b9f5efdb40b4862c9a Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Fri, 5 Jul 2013 22:06:23 +0000 Subject: [PATCH] Rampage turned into api-based scripted effect scripted witch_maw_nephilim.txt 2nd ability and removed hardcode added some syntax sugar in TriggerType.java --- res/cardsfolder/w/witch_maw_nephilim.txt | 4 +- .../java/forge/card/trigger/TriggerType.java | 11 +-- .../java/forge/game/combat/CombatUtil.java | 83 +++---------------- 3 files changed, 17 insertions(+), 81 deletions(-) diff --git a/res/cardsfolder/w/witch_maw_nephilim.txt b/res/cardsfolder/w/witch_maw_nephilim.txt index 6f342f2b583..8ae03dabaee 100644 --- a/res/cardsfolder/w/witch_maw_nephilim.txt +++ b/res/cardsfolder/w/witch_maw_nephilim.txt @@ -1,10 +1,12 @@ Name:Witch-Maw Nephilim ManaCost:G W U B Types:Creature Nephilim -Text:Whenever CARDNAME attacks, it gains trample until end of turn if its power is 10 or greater. PT:1/1 T:Mode$ SpellCast | ValidCard$ Card | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigPutCounter | TriggerDescription$ Whenever you cast a spell, you may put two +1/+1 counters on CARDNAME. +T:Mode$ Attacks | ValidCard$ Card.Self | TriggerZones$ Battlefield | CheckSVar$ MyPower | SVarCompare$ GT9 | Execute$ PumpTrample | TriggerDescription$ Whenever CARDNAME attacks, it gains trample until end of turn if its power is 10 or greater. +SVar:PumpTrample:AB$ Pump | Cost$ 0 | Defined$ Self | KW$ Trample SVar:TrigPutCounter:AB$PutCounter | Cost$ 0 | Defined$ Self | CounterType$ P1P1 | CounterNum$ 2 SVar:BuffedBy:Card +SVar:MyPower:Count$CardPower SVar:Picture:http://www.wizards.com/global/images/magic/general/witch_maw_nephilim.jpg Oracle:Whenever you cast a spell, you may put two +1/+1 counters on Witch-Maw Nephilim.\nWhenever Witch-Maw Nephilim attacks, it gains trample until end of turn if its power is 10 or greater. \ No newline at end of file diff --git a/src/main/java/forge/card/trigger/TriggerType.java b/src/main/java/forge/card/trigger/TriggerType.java index 0f15135c58c..85d4eb536c9 100644 --- a/src/main/java/forge/card/trigger/TriggerType.java +++ b/src/main/java/forge/card/trigger/TriggerType.java @@ -108,16 +108,7 @@ public enum TriggerType { Trigger res = c.newInstance(mapParams, host, intrinsic); res.setMode(this); return res; - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. - e.printStackTrace(); - } catch (InstantiationException e) { - // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. - e.printStackTrace(); - } catch (InvocationTargetException e) { + } catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException e) { // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. e.printStackTrace(); } diff --git a/src/main/java/forge/game/combat/CombatUtil.java b/src/main/java/forge/game/combat/CombatUtil.java index c38793c4338..c9282f24efa 100644 --- a/src/main/java/forge/game/combat/CombatUtil.java +++ b/src/main/java/forge/game/combat/CombatUtil.java @@ -955,41 +955,6 @@ public class CombatUtil { } // creatureAttacked // Annihilator - - if (c.getName().equals("Witch-Maw Nephilim") && !c.getDamageHistory().getCreatureAttackedThisCombat() - && (c.getNetAttack() >= 10)) { - final Card charger = c; - final Ability ability2 = new Ability(c, ManaCost.ZERO) { - @Override - public void resolve() { - - final Command untilEOT = new Command() { - private static final long serialVersionUID = -1703473800920781454L; - - @Override - public void run() { - if (charger.isInPlay()) { - charger.removeIntrinsicKeyword("Trample"); - } - } - }; // Command - - if (charger.isInPlay()) { - charger.addIntrinsicKeyword("Trample"); - - game.getEndOfTurn().addUntil(untilEOT); - } - } // resolve - }; // ability - - final StringBuilder sb2 = new StringBuilder(); - sb2.append(c.getName()).append(" - gains trample until end of turn if its power is 10 or greater."); - ability2.setStackDescription(sb2.toString()); - - game.getStack().add(ability2); - - } // Witch-Maw Nephilim - c.getDamageHistory().setCreatureAttackedThisCombat(true); c.getController().setAttackedWithCreatureThisTurn(true); c.getController().incrementAttackersDeclaredThisTurn(); @@ -1085,8 +1050,11 @@ public class CombatUtil { String desc = String.format("StackDescription$ Flanking (The blocking %s gets -1/-1 until end of turn)", b.getName()); SpellAbility ability = AbilityFactory.getAbility(effect + desc, a); + ability.setActivatingPlayer(a.getController()); + ability.setDescription(ability.getStackDescription()); ability.setTrigger(true); - game.getStack().add(ability); + + game.getStack().addSimultaneousStackEntry(ability); } } // flanking @@ -1136,42 +1104,17 @@ public class CombatUtil { * - the number of creatures blocking this rampaging creature */ private static void executeRampageAbility(final Game game, final Card c, final int magnitude, final int numBlockers) { - final Card crd = c; - final int pump = magnitude; - Ability ability; + // numBlockers starts with 1 since it is for every creature beyond the first + for (int i = 1; i < numBlockers; i++) { + String effect = String.format("AB$ Pump | Cost$ 0 | Defined$ CardUID_%d | NumAtt$ +%d | NumDef$ +%d | ", c.getUniqueNumber(), magnitude, magnitude); + String desc = String.format("StackDescription$ Rampage %d (Whenever CARDNAME becomes blocked, it gets +%d/+%d until end of turn for each creature blocking it beyond the first.)", magnitude, magnitude ); - // numBlockers -1 since it is for every creature beyond the first - for (int i = 0; i < (numBlockers - 1); i++) { - ability = new Ability(c, ManaCost.ZERO) { - @Override - public void resolve() { - final Command untilEOT = new Command() { - private static final long serialVersionUID = -3215615538474963181L; + SpellAbility ability = AbilityFactory.getAbility(effect + desc, c); + ability.setActivatingPlayer(c.getController()); + ability.setDescription(ability.getStackDescription()); + ability.setTrigger(true); - @Override - public void run() { - if (crd.isInPlay()) { - crd.addTempAttackBoost(-pump); - crd.addTempDefenseBoost(-pump); - } - } - }; // Command - - if (crd.isInPlay()) { - crd.addTempAttackBoost(pump); - crd.addTempDefenseBoost(pump); - - game.getEndOfTurn().addUntil(untilEOT); - } - } // resolve - - }; // ability - - final StringBuilder sb = new StringBuilder(); - sb.append(c).append(" - (Rampage) gets +").append(pump).append("/+").append(pump).append(" until EOT."); - ability.setStackDescription(sb.toString()); - - game.getStack().add(ability); + game.getStack().addSimultaneousStackEntry(ability); } }