diff --git a/Mage.Sets/src/mage/cards/v/VoiceOfResurgence.java b/Mage.Sets/src/mage/cards/v/VoiceOfResurgence.java index 059572e9e7..ab0e397414 100644 --- a/Mage.Sets/src/mage/cards/v/VoiceOfResurgence.java +++ b/Mage.Sets/src/mage/cards/v/VoiceOfResurgence.java @@ -3,13 +3,21 @@ package mage.cards.v; import java.util.UUID; import mage.MageInt; +import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.DiesTriggeredAbility; +import mage.abilities.common.SpellCastOpponentTriggeredAbility; +import mage.abilities.condition.common.MyTurnCondition; +import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.meta.OrTriggeredAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; +import mage.filter.FilterSpell; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; @@ -31,7 +39,14 @@ public final class VoiceOfResurgence extends CardImpl { this.toughness = new MageInt(2); // Whenever an opponent casts a spell during your turn or when Voice of Resurgence dies, create a green and white Elemental creature token with "This creature's power and toughness are each equal to the number of creatures you control." - this.addAbility(new VoiceOfResurgenceTriggeredAbility()); + OrTriggeredAbility ability = new OrTriggeredAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new VoiceOfResurgenceToken()), + new ConditionalTriggeredAbility( + new SpellCastOpponentTriggeredAbility(null, new FilterSpell("a spell"), false), + MyTurnCondition.instance, + "Whenever an opponent casts a spell during your turn, "), + new DiesTriggeredAbility(null, false)); + ability.setLeavesTheBattlefieldTrigger(true); + this.addAbility(ability); } @@ -43,50 +58,4 @@ public final class VoiceOfResurgence extends CardImpl { public VoiceOfResurgence copy() { return new VoiceOfResurgence(this); } -} - -class VoiceOfResurgenceTriggeredAbility extends TriggeredAbilityImpl { - - public VoiceOfResurgenceTriggeredAbility() { - super(Zone.BATTLEFIELD, new CreateTokenEffect(new VoiceOfResurgenceToken()), false); - setLeavesTheBattlefieldTrigger(true); - } - - public VoiceOfResurgenceTriggeredAbility(final VoiceOfResurgenceTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.SPELL_CAST || event.getType() == EventType.ZONE_CHANGE; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - // Opponent casts spell during your turn - if (event.getType() == GameEvent.EventType.SPELL_CAST) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null - && game.getOpponents(super.getControllerId()).contains(spell.getControllerId()) - && game.getActivePlayerId().equals(super.getControllerId())) { - return true; - } - } - // Voice of Resurgence Dies - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && getSourceId().equals(event.getTargetId())) { - ZoneChangeEvent zce = (ZoneChangeEvent) event; - return zce.getFromZone() == Zone.BATTLEFIELD && zce.getToZone() == Zone.GRAVEYARD; - } - return false; - } - - @Override - public String getRule() { - return "Whenever an opponent casts a spell during your turn or when {this} dies, create a green and white Elemental creature token with \"This creature's power and toughness are each equal to the number of creatures you control."; - } - - @Override - public VoiceOfResurgenceTriggeredAbility copy() { - return new VoiceOfResurgenceTriggeredAbility(this); - } -} +} \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalTriggeredAbility.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalTriggeredAbility.java index 0410a5b3a6..8c4f60a047 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalTriggeredAbility.java @@ -48,6 +48,8 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { + System.out.println("Source ID: "+this.getControllerId()); + System.out.println("Active player ID: "+game.getActivePlayerId()); return condition.apply(game, this); } diff --git a/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java b/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java index 1d14b10481..053dccf41a 100644 --- a/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java @@ -38,7 +38,10 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl { public OrTriggeredAbility(OrTriggeredAbility ability) { super(ability); - this.triggeredAbilities = ability.triggeredAbilities; + this.triggeredAbilities = new TriggeredAbility[ability.triggeredAbilities.length]; + for (int i = 0; i < this.triggeredAbilities.length; i++){ + this.triggeredAbilities[i] = ability.triggeredAbilities[i].copy(); + } this.ruleTrigger = ability.ruleTrigger; } @@ -122,4 +125,24 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl { ability.setSourceObject(sourceObject, game); } } + + @Override + public boolean checkInterveningIfClause(Game game) { + for (TriggeredAbility ability : triggeredAbilities) { + if (!ability.checkInterveningIfClause(game)){ + return false; + } + } + return true; + } + + @Override + public boolean checkIfClause(Game game) { + for (TriggeredAbility ability : triggeredAbilities) { + if (!ability.checkIfClause(game)){ + return false; + } + } + return true; + } }