[DSK] Implement Enduring Innocence

This commit is contained in:
theelk801 2024-09-01 14:38:48 -04:00
parent ac322a11cd
commit ad7b65d317
4 changed files with 161 additions and 84 deletions

View file

@ -0,0 +1,61 @@
package mage.cards.e;
import mage.MageInt;
import mage.abilities.common.EnduringGlimmerTriggeredAbility;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.mageobject.PowerPredicate;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class EnduringInnocence extends CardImpl {
private static final FilterPermanent filter = new FilterControlledCreaturePermanent();
static {
filter.add(AnotherPredicate.instance);
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, 3));
}
public EnduringInnocence(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{W}{W}");
this.subtype.add(SubType.SHEEP);
this.subtype.add(SubType.GLIMMER);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// Lifelink
this.addAbility(LifelinkAbility.getInstance());
// Whenever one or more other creatures you control with power 2 or less enter, draw a card. This ability triggers only once each turn.
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(
new DrawCardSourceControllerEffect(1), filter
).setTriggersLimitEachTurn(1)
.setTriggerPhrase("Whenever one or more other creatures you control with power 2 or less enter, "));
// When Enduring Innocence dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment.
this.addAbility(new EnduringGlimmerTriggeredAbility());
}
private EnduringInnocence(final EnduringInnocence card) {
super(card);
}
@Override
public EnduringInnocence copy() {
return new EnduringInnocence(this);
}
}

View file

@ -1,25 +1,16 @@
package mage.cards.e;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.common.EnduringGlimmerTriggeredAbility;
import mage.abilities.common.GainLifeControllerTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.SavedGainedLifeValue;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
@ -42,11 +33,7 @@ public final class EnduringTenacity extends CardImpl {
this.addAbility(ability);
// When Enduring Tenacity dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new DiesSourceTriggeredAbility(new EnduringTenacityReturnEffect()),
EnduringTenacityCondition.instance,
"When {this} dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment"
));
this.addAbility(new EnduringGlimmerTriggeredAbility());
}
private EnduringTenacity(final EnduringTenacity card) {
@ -58,70 +45,3 @@ public final class EnduringTenacity extends CardImpl {
return new EnduringTenacity(this);
}
}
enum EnduringTenacityCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) source.getEffects().get(0).getValue("permanentLeftBattlefield");
return permanent != null && permanent.isCreature(game);
}
}
class EnduringTenacityReturnEffect extends OneShotEffect {
EnduringTenacityReturnEffect() {
super(Outcome.Benefit);
}
private EnduringTenacityReturnEffect(final EnduringTenacityReturnEffect effect) {
super(effect);
}
@Override
public EnduringTenacityReturnEffect copy() {
return new EnduringTenacityReturnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (player == null || card == null) {
return false;
}
game.addEffect(new EnduringTenacityTypeEffect()
.setTargetPointer(new FixedTarget(new MageObjectReference(card, game, 1))), source);
return player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
class EnduringTenacityTypeEffect extends ContinuousEffectImpl {
EnduringTenacityTypeEffect() {
super(Duration.Custom, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
}
private EnduringTenacityTypeEffect(final EnduringTenacityTypeEffect effect) {
super(effect);
}
@Override
public EnduringTenacityTypeEffect copy() {
return new EnduringTenacityTypeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
discard();
return false;
}
permanent.retainAllEnchantmentSubTypes(game);
permanent.removeAllCardTypes(game);
permanent.addCardType(game, CardType.ENCHANTMENT);
return true;
}
}

View file

@ -25,6 +25,7 @@ public final class DuskmournHouseOfHorror extends ExpansionSet {
cards.add(new SetCardInfo("Cursed Recording", 131, Rarity.RARE, mage.cards.c.CursedRecording.class));
cards.add(new SetCardInfo("Disturbing Mirth", 212, Rarity.UNCOMMON, mage.cards.d.DisturbingMirth.class));
cards.add(new SetCardInfo("Doomsday Excruciator", 94, Rarity.RARE, mage.cards.d.DoomsdayExcruciator.class));
cards.add(new SetCardInfo("Enduring Innocence", 6, Rarity.RARE, mage.cards.e.EnduringInnocence.class));
cards.add(new SetCardInfo("Enduring Tenacity", 95, Rarity.RARE, mage.cards.e.EnduringTenacity.class));
cards.add(new SetCardInfo("Fear of Immobility", 10, Rarity.COMMON, mage.cards.f.FearOfImmobility.class));
cards.add(new SetCardInfo("Fear of Lost Teeth", 97, Rarity.COMMON, mage.cards.f.FearOfLostTeeth.class));

View file

@ -0,0 +1,95 @@
package mage.abilities.common;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
* @author TheElk801, PurpleCrowbar
*/
public class EnduringGlimmerTriggeredAbility extends DiesSourceTriggeredAbility {
public EnduringGlimmerTriggeredAbility() {
super(new EnduringGlimmerReturnEffect());
}
private EnduringGlimmerTriggeredAbility(final EnduringGlimmerTriggeredAbility ability) {
super(ability);
}
@Override
public EnduringGlimmerTriggeredAbility copy() {
return new EnduringGlimmerTriggeredAbility(this);
}
@Override
public boolean checkInterveningIfClause(Game game) {
Permanent permanent = (Permanent) this.getEffects().get(0).getValue("permanentLeftBattlefield");
return permanent != null && permanent.isCreature(game);
}
}
class EnduringGlimmerReturnEffect extends OneShotEffect {
EnduringGlimmerReturnEffect() {
super(Outcome.Benefit);
staticText = "if it was a creature, return it to the battlefield under its owner's control. It's an enchantment";
}
private EnduringGlimmerReturnEffect(final EnduringGlimmerReturnEffect effect) {
super(effect);
}
@Override
public EnduringGlimmerReturnEffect copy() {
return new EnduringGlimmerReturnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (player == null || card == null) {
return false;
}
game.addEffect(new EnduringGlimmerTypeEffect()
.setTargetPointer(new FixedTarget(new MageObjectReference(card, game, 1))), source);
return player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
class EnduringGlimmerTypeEffect extends ContinuousEffectImpl {
EnduringGlimmerTypeEffect() {
super(Duration.Custom, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
}
private EnduringGlimmerTypeEffect(final EnduringGlimmerTypeEffect effect) {
super(effect);
}
@Override
public EnduringGlimmerTypeEffect copy() {
return new EnduringGlimmerTypeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
discard();
return false;
}
permanent.retainAllEnchantmentSubTypes(game);
permanent.removeAllCardTypes(game);
permanent.addCardType(game, CardType.ENCHANTMENT);
return true;
}
}