[ORI] refactor some TDFCs

This commit is contained in:
theelk801 2025-07-28 14:00:19 -04:00
parent 69b82f4068
commit d29daa2f85
7 changed files with 72 additions and 104 deletions

View file

@ -1,13 +1,12 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.constants.Pronoun;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceDealtDamageCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
@ -23,8 +22,9 @@ import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetPlayerOrPlaneswalker;
import mage.watchers.common.DamageDoneWatcher;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class ChandraFireOfKaladesh extends CardImpl {
@ -35,6 +35,8 @@ public final class ChandraFireOfKaladesh extends CardImpl {
filter.add(new ColorPredicate(ObjectColor.RED));
}
private static final Condition condition = new SourceDealtDamageCondition(3);
public ChandraFireOfKaladesh(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{R}");
this.supertype.add(SuperType.LEGENDARY);
@ -51,10 +53,11 @@ public final class ChandraFireOfKaladesh extends CardImpl {
// {T}: Chandra, Fire of Kaladesh deals 1 damage to target player. If Chandra has dealt 3 or more damage this turn, exile her, then return her to the battlefield transformed under her owner's control.
this.addAbility(new TransformAbility());
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new TapSourceCost());
ability.addEffect(new ConditionalOneShotEffect(new ExileAndReturnSourceEffect(PutCards.BATTLEFIELD_TRANSFORMED,Pronoun.SHE), new SourceDealtDamageCondition(3)));
ability.addEffect(new ConditionalOneShotEffect(
new ExileAndReturnSourceEffect(PutCards.BATTLEFIELD_TRANSFORMED, Pronoun.SHE), condition
));
ability.addTarget(new TargetPlayerOrPlaneswalker());
this.addAbility(ability, new DamageDoneWatcher());
}
private ChandraFireOfKaladesh(final ChandraFireOfKaladesh card) {

View file

@ -47,7 +47,6 @@ public final class ChandraRoaringFlame extends CardImpl {
//-7: Chandra, Roaring Flame deals 6 damage to each opponent. Each player dealt damage this way gets an emblem with "At the beginning of your upkeep, this emblem deals 3 damage to you."
this.addAbility(new LoyaltyAbility(new ChandraRoaringFlameEmblemEffect(), -7));
}
private ChandraRoaringFlame(final ChandraRoaringFlame card) {
@ -79,20 +78,19 @@ class ChandraRoaringFlameEmblemEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<Player> opponentsEmblem = new ArrayList<>();
for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
if (opponent.damage(6, source.getSourceId(), source, game) > 0) {
opponentsEmblem.add(opponent);
}
}
}
for (Player opponent : opponentsEmblem) {
game.addEmblem(new ChandraRoaringFlameEmblem(), source.getSourceObject(game), opponent.getId());
if (controller == null) {
return false;
}
List<Player> opponentsEmblem = new ArrayList<>();
for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null && opponent.damage(6, source, game) > 0) {
opponentsEmblem.add(opponent);
}
}
for (Player opponent : opponentsEmblem) {
game.addEmblem(new ChandraRoaringFlameEmblem(), source.getSourceObject(game), opponent.getId());
}
return false;
}
}

View file

@ -1,10 +1,8 @@
package mage.cards.g;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.RequirementEffect;
import mage.abilities.effects.common.PreventAllDamageToSourceEffect;
import mage.abilities.effects.common.UntapTargetEffect;
@ -14,12 +12,11 @@ import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.TokenImpl;
import mage.target.TargetPermanent;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetOpponentsCreaturePermanent;
import java.util.UUID;
@ -28,12 +25,6 @@ import java.util.UUID;
*/
public final class GideonBattleForged extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(TargetController.OPPONENT.getControllerPredicate());
}
public GideonBattleForged(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "");
this.supertype.add(SuperType.LEGENDARY);
@ -46,27 +37,26 @@ public final class GideonBattleForged extends CardImpl {
this.setStartingLoyalty(3);
// +2: Up to one target creature an opponent controls attacks Gideon, Battle-Forged during its controller's next turn if able.
LoyaltyAbility loyaltyAbility = new LoyaltyAbility(new GideonBattleForgedAttacksIfAbleTargetEffect(Duration.Custom), 2);
loyaltyAbility.addTarget(new TargetPermanent(0, 1, filter));
this.addAbility(loyaltyAbility);
Ability ability = new LoyaltyAbility(new GideonBattleForgedEffect(), 2);
ability.addTarget(new TargetOpponentsCreaturePermanent(0, 1));
this.addAbility(ability);
// +1: Until your next turn, target creature gains indestructible. Untap that creature.
Effect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.UntilYourNextTurn);
effect.setText("Until your next turn, target creature gains indestructible");
loyaltyAbility = new LoyaltyAbility(effect, 1);
loyaltyAbility.addTarget(new TargetCreaturePermanent());
effect = new UntapTargetEffect();
effect.setText("Untap that creature");
loyaltyAbility.addEffect(effect);
this.addAbility(loyaltyAbility);
ability = new LoyaltyAbility(new GainAbilityTargetEffect(
IndestructibleAbility.getInstance(), Duration.UntilYourNextTurn
).setText("Until your next turn, target creature gains indestructible"), 1);
ability.addEffect(new UntapTargetEffect().setText("Untap that creature"));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
// 0: Until end of turn, Gideon, Battle-Forged becomes a 4/4 Human Soldier creature with indestructible that's still a planeswalker. Prevent all damage that would be dealt to him this turn.
LoyaltyAbility ability3 = new LoyaltyAbility(new BecomesCreatureSourceEffect(new GideonBattleForgedToken(), CardType.PLANESWALKER, Duration.EndOfTurn), 0);
effect = new PreventAllDamageToSourceEffect(Duration.EndOfTurn);
effect.setText("Prevent all damage that would be dealt to him this turn");
ability3.addEffect(effect);
this.addAbility(ability3);
ability = new LoyaltyAbility(new BecomesCreatureSourceEffect(new CreatureToken(
4, 4, "4/4 Human Soldier creature " +
"with indestructible", SubType.HUMAN, SubType.SOLDIER
).withAbility(IndestructibleAbility.getInstance()), CardType.PLANESWALKER, Duration.EndOfTurn), 0);
ability.addEffect(new PreventAllDamageToSourceEffect(Duration.EndOfTurn)
.setText("Prevent all damage that would be dealt to him this turn"));
this.addAbility(ability);
}
private GideonBattleForged(final GideonBattleForged card) {
@ -79,44 +69,23 @@ public final class GideonBattleForged extends CardImpl {
}
}
class GideonBattleForgedToken extends TokenImpl {
public GideonBattleForgedToken() {
super("", "4/4 Human Soldier creature with indestructible");
cardType.add(CardType.CREATURE);
subtype.add(SubType.HUMAN);
subtype.add(SubType.SOLDIER);
power = new MageInt(4);
toughness = new MageInt(4);
this.addAbility(IndestructibleAbility.getInstance());
}
private GideonBattleForgedToken(final GideonBattleForgedToken token) {
super(token);
}
public GideonBattleForgedToken copy() {
return new GideonBattleForgedToken(this);
}
}
class GideonBattleForgedAttacksIfAbleTargetEffect extends RequirementEffect {
class GideonBattleForgedEffect extends RequirementEffect {
protected MageObjectReference targetPermanentReference;
public GideonBattleForgedAttacksIfAbleTargetEffect(Duration duration) {
super(duration);
staticText = "Up to one target creature an opponent controls attacks {this} during its controller's next turn if able";
GideonBattleForgedEffect() {
super(Duration.Custom);
staticText = "up to one target creature an opponent controls attacks {this} during its controller's next turn if able";
}
private GideonBattleForgedAttacksIfAbleTargetEffect(final GideonBattleForgedAttacksIfAbleTargetEffect effect) {
private GideonBattleForgedEffect(final GideonBattleForgedEffect effect) {
super(effect);
this.targetPermanentReference = effect.targetPermanentReference;
}
@Override
public GideonBattleForgedAttacksIfAbleTargetEffect copy() {
return new GideonBattleForgedAttacksIfAbleTargetEffect(this);
public GideonBattleForgedEffect copy() {
return new GideonBattleForgedEffect(this);
}
@Override
@ -143,17 +112,16 @@ class GideonBattleForgedAttacksIfAbleTargetEffect extends RequirementEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(getTargetPointer().getFirst(game, source))) {
if (game.isActivePlayer(permanent.getControllerId())) {
Permanent planeswalker = game.getPermanent(source.getSourceId());
if (planeswalker != null) {
return true;
} else {
discard();
}
}
if (!permanent.getId().equals(getTargetPointer().getFirst(game, source))
|| !game.isActivePlayer(permanent.getControllerId())) {
return false;
}
return false;
Permanent planeswalker = source.getSourcePermanentIfItStillExists(game);
if (planeswalker == null) {
discard();
return false;
}
return true;
}
@Override
@ -170,5 +138,4 @@ class GideonBattleForgedAttacksIfAbleTargetEffect extends RequirementEffect {
public boolean mustBlock(Game game) {
return false;
}
}

View file

@ -2,7 +2,6 @@ package mage.cards.j;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.GetEmblemEffect;
import mage.abilities.effects.common.MayCastTargetCardEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
@ -35,9 +34,9 @@ public final class JaceTelepathUnbound extends CardImpl {
this.setStartingLoyalty(5);
// +1: Up to one target creature gets -2/-0 until your next turn.
Effect effect = new BoostTargetEffect(-2, 0, Duration.UntilYourNextTurn);
effect.setText("Up to one target creature gets -2/-0 until your next turn");
Ability ability = new LoyaltyAbility(effect, 1);
Ability ability = new LoyaltyAbility(new BoostTargetEffect(
-2, 0, Duration.UntilYourNextTurn
).setText("Up to one target creature gets -2/-0 until your next turn"), 1);
ability.addTarget(new TargetCreaturePermanent(0, 1));
this.addAbility(ability);

View file

@ -1,15 +1,12 @@
package mage.cards.j;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.constants.Pronoun;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.CardsInControllerGraveyardCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawDiscardControllerEffect;
import mage.abilities.effects.common.ExileAndReturnSourceEffect;
import mage.abilities.keyword.TransformAbility;
@ -17,14 +14,17 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class JaceVrynsProdigy extends CardImpl {
private static final Condition condition = new CardsInControllerGraveyardCondition(5);
public JaceVrynsProdigy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
@ -35,11 +35,13 @@ public final class JaceVrynsProdigy extends CardImpl {
// {T}: Draw a card, then discard a card. If there are five or more cards in your graveyard, exile Jace, Vryn's Prodigy, then return him to the battefield transformed under his owner's control.
this.addAbility(new TransformAbility());
Ability ability = new SimpleActivatedAbility(new DrawDiscardControllerEffect(1, 1), new TapSourceCost());
Effect effect = new ConditionalOneShotEffect(new ExileAndReturnSourceEffect(PutCards.BATTLEFIELD_TRANSFORMED,Pronoun.HE), new CardsInControllerGraveyardCondition(5));
ability.addEffect(effect);
Ability ability = new SimpleActivatedAbility(
new DrawDiscardControllerEffect(1, 1), new TapSourceCost()
);
ability.addEffect(new ConditionalOneShotEffect(
new ExileAndReturnSourceEffect(PutCards.BATTLEFIELD_TRANSFORMED, Pronoun.HE), condition
));
this.addAbility(ability);
}
private JaceVrynsProdigy(final JaceVrynsProdigy card) {

View file

@ -23,7 +23,7 @@ import java.util.UUID;
*/
public final class LilianaDefiantNecromancer extends CardImpl {
protected static final FilterCreatureCard filter = new FilterCreatureCard("nonlegendary creature card with mana value X from your graveyard");
private static final FilterCreatureCard filter = new FilterCreatureCard("nonlegendary creature card with mana value X from your graveyard");
static {
filter.add(Predicates.not(SuperType.LEGENDARY.getPredicate()));

View file

@ -1,7 +1,6 @@
package mage.cards.l;
import mage.MageInt;
import mage.constants.Pronoun;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.ExileAndReturnSourceEffect;
@ -10,7 +9,8 @@ import mage.abilities.keyword.TransformAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.permanent.token.ZombieToken;
@ -22,10 +22,9 @@ import java.util.UUID;
*/
public final class LilianaHereticalHealer extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another nontoken creature you control");
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("another nontoken creature you control");
static {
filter.add(TargetController.YOU.getControllerPredicate());
filter.add(AnotherPredicate.instance);
filter.add(TokenPredicate.FALSE);
}