- Experimental: fixed state triggers so they will trigger during the middle of the resolution of a spell or ability. (e.g. Cloudshift an Enchantment creature would fire Tethered Griffin's trigger)

This commit is contained in:
swordshine
2014-02-25 05:46:33 +00:00
parent 48f53491c6
commit 31e5b0d4c0
5 changed files with 24 additions and 8 deletions

View File

@@ -763,6 +763,9 @@ public class GameAction {
game.fireEvent(new GameEventCardStatsChanged(affectedCards)); game.fireEvent(new GameEventCardStatsChanged(affectedCards));
} }
final HashMap<String, Object> runParams = new HashMap<String, Object>();
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
} }
/** /**
@@ -802,9 +805,6 @@ public class GameAction {
this.checkStaticAbilities(); this.checkStaticAbilities();
final HashMap<String, Object> runParams = new HashMap<String, Object>();
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
for (Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
for (Card c : p.getCardsIn(ZoneType.Battlefield)) { for (Card c : p.getCardsIn(ZoneType.Battlefield)) {
if (!c.getController().equals(p)) { // should not be here if (!c.getController().equals(p)) { // should not be here

View File

@@ -155,8 +155,9 @@ public class TriggerHandler {
} }
//runWaitingTrigger(new TriggerWaiting(mode, runParams)); //runWaitingTrigger(new TriggerWaiting(mode, runParams));
if (mode == TriggerType.Always) {
if (game.getStack().isFrozen() || holdTrigger) { runStateTrigger(runParams);
} else if (game.getStack().isFrozen() || holdTrigger) {
waitingTriggers.add(new TriggerWaiting(mode, runParams)); waitingTriggers.add(new TriggerWaiting(mode, runParams));
} else { } else {
runWaitingTrigger(new TriggerWaiting(mode, runParams)); runWaitingTrigger(new TriggerWaiting(mode, runParams));
@@ -164,6 +165,21 @@ public class TriggerHandler {
// Tell auto stop to stop // Tell auto stop to stop
} }
public final boolean runStateTrigger(Map<String, Object> runParams) {
boolean checkStatics = false;
// only cards in play can run state triggers
List<Card> allCards = new ArrayList<Card>(game.getCardsIn(ZoneType.listValueOf("Battlefield,Command")));
for (final Card c : allCards) {
for (final Trigger t : c.getTriggers()) {
if (canRunTrigger(t, TriggerType.Always, runParams)) {
this.runSingleTrigger(t, runParams);
checkStatics = true;
}
}
}
return checkStatics;
}
public final boolean runWaitingTriggers() { public final boolean runWaitingTriggers() {
ArrayList<TriggerWaiting> waiting = new ArrayList<TriggerWaiting>(waitingTriggers); ArrayList<TriggerWaiting> waiting = new ArrayList<TriggerWaiting>(waitingTriggers);
waitingTriggers.clear(); waitingTriggers.clear();

View File

@@ -2,7 +2,7 @@ Name:Bronze Bombshell
ManaCost:4 ManaCost:4
Types:Artifact Creature Construct Types:Artifact Creature Construct
PT:4/1 PT:4/1
T:Mode$ Always | IsPresent$ Card.Self+OwnerDoesntControl | Execute$ TrigSac | TriggerDescription$ When a player other than CARDNAME's owner controls it, that player sacrifices it. If the player does, CARDNAME deals 7 damage to him or her. T:Mode$ Always | TriggerZones$ Battlefield | IsPresent$ Card.Self+OwnerDoesntControl | Execute$ TrigSac | TriggerDescription$ When a player other than CARDNAME's owner controls it, that player sacrifices it. If the player does, CARDNAME deals 7 damage to him or her.
SVar:TrigSac:AB$SacrificeAll | Cost$ 0 | Defined$ Self | RememberSacrificed$ True | SubAbility$ DBDmg SVar:TrigSac:AB$SacrificeAll | Cost$ 0 | Defined$ Self | RememberSacrificed$ True | SubAbility$ DBDmg
SVar:DBDmg:DB$DealDamage | Defined$ You | NumDmg$ 7 | CheckSVar$ X | SVarCompare$ GE1 | References$ X SVar:DBDmg:DB$DealDamage | Defined$ You | NumDmg$ 7 | CheckSVar$ X | SVarCompare$ GE1 | References$ X
SVar:X:Remembered$Amount SVar:X:Remembered$Amount

View File

@@ -2,7 +2,7 @@ Name:Garruk Relentless
ManaCost:3 G ManaCost:3 G
Types:Planeswalker Garruk Types:Planeswalker Garruk
Loyalty:3 Loyalty:3
T:Mode$ Always | IsPresent$ Card.Self+counters_LE2_LOYALTY | Execute$ TrigTransform | TriggerDescription$ When CARDNAME has two or fewer loyalty counters on him, transform him. T:Mode$ Always | TriggerZones$ Battlefield | IsPresent$ Card.Self+counters_LE2_LOYALTY | Execute$ TrigTransform | TriggerDescription$ When CARDNAME has two or fewer loyalty counters on him, transform him.
A:AB$ DealDamage | Cost$ AddCounter<0/LOYALTY> | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumDmg$ 3 | SubAbility$ DamageThis | Planeswalker$ True | SpellDescription$ CARDNAME deals 3 damage to target creature. That creature deals damage equal to its power to him. A:AB$ DealDamage | Cost$ AddCounter<0/LOYALTY> | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumDmg$ 3 | SubAbility$ DamageThis | Planeswalker$ True | SpellDescription$ CARDNAME deals 3 damage to target creature. That creature deals damage equal to its power to him.
A:AB$ Token | Cost$ AddCounter<0/LOYALTY> | TokenAmount$ 1 | TokenName$ Wolf | TokenColors$ Green | TokenTypes$ Creature,Wolf | TokenOwner$ You | TokenPower$ 2 | TokenToughness$ 2 | Planeswalker$ True | References$ Y | SpellDescription$ Put a 2/2 green Wolf creature token onto the battlefield. A:AB$ Token | Cost$ AddCounter<0/LOYALTY> | TokenAmount$ 1 | TokenName$ Wolf | TokenColors$ Green | TokenTypes$ Creature,Wolf | TokenOwner$ You | TokenPower$ 2 | TokenToughness$ 2 | Planeswalker$ True | References$ Y | SpellDescription$ Put a 2/2 green Wolf creature token onto the battlefield.
SVar:DamageThis:DB$ DealDamage | Defined$ Self | DamageSource$ Targeted | NumDmg$ Y SVar:DamageThis:DB$ DealDamage | Defined$ Self | DamageSource$ Targeted | NumDmg$ Y

View File

@@ -4,7 +4,7 @@ Types:Artifact Creature Scarecrow
PT:4/4 PT:4/4
K:ETBReplacement:Other:ChooseColor K:ETBReplacement:Other:ChooseColor
SVar:ChooseColor:DB$ ChooseColor | Defined$ You | SpellDescription$ As CARDNAME enters the battlefield, choose a color. | AILogic$ MostProminentComputerControls SVar:ChooseColor:DB$ ChooseColor | Defined$ You | SpellDescription$ As CARDNAME enters the battlefield, choose a color. | AILogic$ MostProminentComputerControls
T:Mode$ Always | CheckSVar$ X | SVarCompare$ EQ0 | TriggerZones$ Battlefield | Static$ True | Execute$ TrigSacrifice | TriggerDescription$ When you control no permanents of the chosen color, sacrifice CARDNAME. T:Mode$ Always | CheckSVar$ X | SVarCompare$ EQ0 | TriggerZones$ Battlefield | Execute$ TrigSacrifice | TriggerDescription$ When you control no permanents of the chosen color, sacrifice CARDNAME.
SVar:TrigSacrifice:AB$ Sacrifice | Cost$ 0 SVar:TrigSacrifice:AB$ Sacrifice | Cost$ 0
SVar:X:Count$Valid Permanent.YouCtrl+ChosenColor SVar:X:Count$Valid Permanent.YouCtrl+ChosenColor
SVar:NeedsToPlay:Permanent.nonColorless+YouCtrl SVar:NeedsToPlay:Permanent.nonColorless+YouCtrl