Update Voice of Resurgence

This commit is contained in:
Noah Gleason 2018-06-24 16:55:15 -04:00
parent 6a2ad691d4
commit 37e800a7dd
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40
3 changed files with 43 additions and 49 deletions

View file

@ -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);
}
}
}

View file

@ -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);
}

View file

@ -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;
}
}