refactor trigger from Aeon Chronicler and its cycle

This commit is contained in:
Susucre 2023-10-22 14:05:47 +02:00
parent b87d8d6a1b
commit 9c17b72892
6 changed files with 83 additions and 175 deletions

View file

@ -1,10 +1,8 @@
package mage.cards.a;
import java.util.Objects;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CounterRemovedFromSourceWhileExiledTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
@ -17,17 +15,16 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class AeonChronicler extends CardImpl {
public AeonChronicler(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{U}");
this.subtype.add(SubType.AVATAR);
this.power = new MageInt(0);
@ -35,12 +32,12 @@ public final class AeonChronicler extends CardImpl {
// Aeon Chronicler's power and toughness are each equal to the number of cards in your hand.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetBasePowerToughnessSourceEffect(CardsInControllerHandCount.instance)));
// Suspend X-{X}{3}{U}. X can't be 0.
this.addAbility(new SuspendAbility(Integer.MAX_VALUE, new ManaCostsImpl<>("{3}{U}"), this, true));
// Whenever a time counter is removed from Aeon Chronicler while it's exiled, draw a card.
this.addAbility(new AeonChroniclerTriggeredAbility());
this.addAbility(new CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType.TIME, new DrawCardSourceControllerEffect(1)));
}
private AeonChronicler(final AeonChronicler card) {
@ -51,31 +48,4 @@ public final class AeonChronicler extends CardImpl {
public AeonChronicler copy() {
return new AeonChronicler(this);
}
}
class AeonChroniclerTriggeredAbility extends TriggeredAbilityImpl {
public AeonChroniclerTriggeredAbility() {
super(Zone.EXILED, new DrawCardSourceControllerEffect(1), false);
setTriggerPhrase("Whenever a time counter is removed from {this} while it's exiled, " );
}
private AeonChroniclerTriggeredAbility(final AeonChroniclerTriggeredAbility ability) {
super(ability);
}
@Override
public AeonChroniclerTriggeredAbility copy() {
return new AeonChroniclerTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return Objects.equals(event.getData(), CounterType.TIME.getName()) && event.getTargetId().equals(this.getSourceId());
}
}
}

View file

@ -1,9 +1,8 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CounterRemovedFromSourceWhileExiledTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
@ -17,12 +16,11 @@ import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.token.SoldierToken;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class BenalishCommander extends CardImpl {
@ -47,7 +45,7 @@ public final class BenalishCommander extends CardImpl {
this.addAbility(new SuspendAbility(Integer.MAX_VALUE, new ManaCostsImpl<>("{W}{W}"), this, true));
// Whenever a time counter is removed from Benalish Commander while it's exiled, create a 1/1 white Soldier creature token.
this.addAbility(new BenalishCommanderTriggeredAbility());
this.addAbility(new CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType.TIME, new CreateTokenEffect(new SoldierToken())));
}
private BenalishCommander(final BenalishCommander card) {
@ -58,31 +56,4 @@ public final class BenalishCommander extends CardImpl {
public BenalishCommander copy() {
return new BenalishCommander(this);
}
}
class BenalishCommanderTriggeredAbility extends TriggeredAbilityImpl {
public BenalishCommanderTriggeredAbility() {
super(Zone.EXILED, new CreateTokenEffect(new SoldierToken()), false);
setTriggerPhrase("Whenever a time counter is removed from {this} while it's exiled, ");
}
private BenalishCommanderTriggeredAbility(final BenalishCommanderTriggeredAbility ability) {
super(ability);
}
@Override
public BenalishCommanderTriggeredAbility copy() {
return new BenalishCommanderTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(CounterType.TIME.getName()) && event.getTargetId().equals(this.getSourceId());
}
}
}

View file

@ -1,10 +1,9 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CounterRemovedFromSourceWhileExiledTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
@ -22,12 +21,12 @@ import mage.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.common.TargetNonBasicLandPermanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class Detritivore extends CardImpl {
@ -46,8 +45,9 @@ public final class Detritivore extends CardImpl {
this.addAbility(new SuspendAbility(Integer.MAX_VALUE, new ManaCostsImpl<>("{3}{R}"), this, true));
// Whenever a time counter is removed from Detritivore while it's exiled, destroy target nonbasic land.
this.addAbility(new DetritivoreTriggeredAbility());
Ability ability = new CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType.TIME, new DestroyTargetEffect());
ability.addTarget(new TargetNonBasicLandPermanent());
this.addAbility(ability);
}
private Detritivore(final Detritivore card) {
@ -60,34 +60,6 @@ public final class Detritivore extends CardImpl {
}
}
class DetritivoreTriggeredAbility extends TriggeredAbilityImpl {
public DetritivoreTriggeredAbility() {
super(Zone.EXILED, new DestroyTargetEffect(), false);
this.addTarget(new TargetNonBasicLandPermanent());
setTriggerPhrase("Whenever a time counter is removed from {this} while it's exiled, ");
}
private DetritivoreTriggeredAbility(final DetritivoreTriggeredAbility ability) {
super(ability);
}
@Override
public DetritivoreTriggeredAbility copy() {
return new DetritivoreTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(CounterType.TIME.getName()) && event.getTargetId().equals(this.getSourceId());
}
}
class NonBasicLandsInOpponentsGraveyards implements DynamicValue {
private static final FilterCard filter = new FilterCard("nonbasic land card");

View file

@ -1,10 +1,9 @@
package mage.cards.f;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CounterRemovedFromSourceWhileExiledTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
@ -20,12 +19,12 @@ import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class FungalBehemoth extends CardImpl {
@ -44,7 +43,13 @@ public final class FungalBehemoth extends CardImpl {
this.addAbility(new SuspendAbility(Integer.MAX_VALUE, new ManaCostsImpl<>("{G}{G}"), this, true));
// Whenever a time counter is removed from Fungal Behemoth while it's exiled, you may put a +1/+1 counter on target creature.
this.addAbility(new FungalBehemothTriggeredAbility());
Ability ability = new CounterRemovedFromSourceWhileExiledTriggeredAbility(
CounterType.TIME,
new AddCountersTargetEffect(CounterType.P1P1.createInstance()),
true
);
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
private FungalBehemoth(final FungalBehemoth card) {
@ -57,34 +62,6 @@ public final class FungalBehemoth extends CardImpl {
}
}
class FungalBehemothTriggeredAbility extends TriggeredAbilityImpl {
public FungalBehemothTriggeredAbility() {
super(Zone.EXILED, new AddCountersTargetEffect(CounterType.P1P1.createInstance()), true);
addTarget(new TargetCreaturePermanent());
setTriggerPhrase("Whenever a time counter is removed from {this} while it's exiled, ");
}
private FungalBehemothTriggeredAbility(final FungalBehemothTriggeredAbility ability) {
super(ability);
}
@Override
public FungalBehemothTriggeredAbility copy() {
return new FungalBehemothTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(CounterType.TIME.getName()) && event.getTargetId().equals(this.getSourceId());
}
}
class P1P1CountersOnControlledCreaturesCount implements DynamicValue {
@Override

View file

@ -1,10 +1,9 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CounterRemovedFromSourceWhileExiledTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
@ -20,12 +19,12 @@ import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.TargetPlayer;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class RoilingHorror extends CardImpl {
@ -46,7 +45,10 @@ public final class RoilingHorror extends CardImpl {
this.addAbility(new SuspendAbility(Integer.MAX_VALUE, new ManaCostsImpl<>("{B}{B}{B}"), this, true));
// Whenever a time counter is removed from Roiling Horror while it's exiled, target player loses 1 life and you gain 1 life.
this.addAbility(new RoilingHorrorTriggeredAbility());
Ability ability = new CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType.TIME, new LoseLifeTargetEffect(1));
ability.addTarget(new TargetPlayer());
ability.addEffect(new GainLifeEffect(1).concatBy("and"));
this.addAbility(ability);
}
@ -60,37 +62,6 @@ public final class RoilingHorror extends CardImpl {
}
}
class RoilingHorrorTriggeredAbility extends TriggeredAbilityImpl {
public RoilingHorrorTriggeredAbility() {
super(Zone.EXILED, new LoseLifeTargetEffect(1), false);
this.addTarget(new TargetPlayer());
Effect effect = new GainLifeEffect(1);
effect.setText("and you gain 1 life");
this.addEffect(effect);
setTriggerPhrase("Whenever a time counter is removed from {this} while it's exiled, ");
}
private RoilingHorrorTriggeredAbility(final RoilingHorrorTriggeredAbility ability) {
super(ability);
}
@Override
public RoilingHorrorTriggeredAbility copy() {
return new RoilingHorrorTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(CounterType.TIME.getName()) && event.getTargetId().equals(this.getSourceId());
}
}
class RoilingHorrorDynamicValue implements DynamicValue {
@Override

View file

@ -0,0 +1,47 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
* @author Susucr
*/
public class CounterRemovedFromSourceWhileExiledTriggeredAbility extends TriggeredAbilityImpl {
private final CounterType counterType;
public CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType counterType, Effect effect) {
this(counterType, effect, false);
}
public CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType counterType, Effect effect, boolean optional) {
super(Zone.EXILED, effect, optional);
this.counterType = counterType;
setTriggerPhrase("Whenever a " + counterType.getName() + " counter is removed from {this} while it's exiled, ");
}
private CounterRemovedFromSourceWhileExiledTriggeredAbility(final CounterRemovedFromSourceWhileExiledTriggeredAbility ability) {
super(ability);
this.counterType = ability.counterType;
}
@Override
public CounterRemovedFromSourceWhileExiledTriggeredAbility copy() {
return new CounterRemovedFromSourceWhileExiledTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(counterType.getName()) && event.getTargetId().equals(this.getSourceId());
}
}