Rampage turned into api-based scripted effect

scripted witch_maw_nephilim.txt 2nd ability and removed hardcode
added some syntax sugar in TriggerType.java
This commit is contained in:
Maxmtg
2013-07-05 22:06:23 +00:00
parent f1f196585d
commit 30f85737c8
3 changed files with 17 additions and 81 deletions

View File

@@ -1,10 +1,12 @@
Name:Witch-Maw Nephilim Name:Witch-Maw Nephilim
ManaCost:G W U B ManaCost:G W U B
Types:Creature Nephilim Types:Creature Nephilim
Text:Whenever CARDNAME attacks, it gains trample until end of turn if its power is 10 or greater.
PT:1/1 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$ 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:TrigPutCounter:AB$PutCounter | Cost$ 0 | Defined$ Self | CounterType$ P1P1 | CounterNum$ 2
SVar:BuffedBy:Card SVar:BuffedBy:Card
SVar:MyPower:Count$CardPower
SVar:Picture:http://www.wizards.com/global/images/magic/general/witch_maw_nephilim.jpg 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. 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.

View File

@@ -108,16 +108,7 @@ public enum TriggerType {
Trigger res = c.newInstance(mapParams, host, intrinsic); Trigger res = c.newInstance(mapParams, host, intrinsic);
res.setMode(this); res.setMode(this);
return res; return res;
} catch (IllegalArgumentException 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();
} 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) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -955,41 +955,6 @@ public class CombatUtil {
} // creatureAttacked } // creatureAttacked
// Annihilator // 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.getDamageHistory().setCreatureAttackedThisCombat(true);
c.getController().setAttackedWithCreatureThisTurn(true); c.getController().setAttackedWithCreatureThisTurn(true);
c.getController().incrementAttackersDeclaredThisTurn(); 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()); 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); SpellAbility ability = AbilityFactory.getAbility(effect + desc, a);
ability.setActivatingPlayer(a.getController());
ability.setDescription(ability.getStackDescription());
ability.setTrigger(true); ability.setTrigger(true);
game.getStack().add(ability);
game.getStack().addSimultaneousStackEntry(ability);
} }
} // flanking } // flanking
@@ -1136,42 +1104,17 @@ public class CombatUtil {
* - the number of creatures blocking this rampaging creature * - the number of creatures blocking this rampaging creature
*/ */
private static void executeRampageAbility(final Game game, final Card c, final int magnitude, final int numBlockers) { private static void executeRampageAbility(final Game game, final Card c, final int magnitude, final int numBlockers) {
final Card crd = c; // numBlockers starts with 1 since it is for every creature beyond the first
final int pump = magnitude; for (int i = 1; i < numBlockers; i++) {
Ability ability; 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 SpellAbility ability = AbilityFactory.getAbility(effect + desc, c);
for (int i = 0; i < (numBlockers - 1); i++) { ability.setActivatingPlayer(c.getController());
ability = new Ability(c, ManaCost.ZERO) { ability.setDescription(ability.getStackDescription());
@Override ability.setTrigger(true);
public void resolve() {
final Command untilEOT = new Command() {
private static final long serialVersionUID = -3215615538474963181L;
@Override game.getStack().addSimultaneousStackEntry(ability);
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);
} }
} }