[NEO] Implemented Crackling Emergence

This commit is contained in:
Evan Kranzler 2022-02-06 19:21:09 -05:00
parent 8cde638137
commit b130e01187
3 changed files with 128 additions and 15 deletions

View file

@ -0,0 +1,113 @@
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAttachedEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class CracklingEmergence extends CardImpl {
public CracklingEmergence(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
this.subtype.add(SubType.AURA);
// Enchant land you control
TargetPermanent auraTarget = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND);
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted land is a 3/3 red Spirit creature with haste. It's still a land.
this.addAbility(new SimpleStaticAbility(new BecomesCreatureAttachedEffect(
new CreatureToken(3, 3)
.withColor("R")
.withSubType(SubType.SPIRIT)
.withAbility(HasteAbility.getInstance()),
"Enchanted land is a 3/3 red Spirit creature with haste. It's still a land.",
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR
)));
// If enchanted land would be destroyed, instead sacrifice Crackling Emergence and that land gains indestructible until end of turn.
this.addAbility(new SimpleStaticAbility(new CracklingEmergenceEffect()));
}
private CracklingEmergence(final CracklingEmergence card) {
super(card);
}
@Override
public CracklingEmergence copy() {
return new CracklingEmergence(this);
}
}
class CracklingEmergenceEffect extends ReplacementEffectImpl {
CracklingEmergenceEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "if enchanted land would be destroyed, instead sacrifice " +
"{this} and that land gains indestructible until end of turn";
}
private CracklingEmergenceEffect(final CracklingEmergenceEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
Permanent enchantedPermanent = game.getPermanent(event.getTargetId());
if (sourcePermanent == null || enchantedPermanent == null) {
return false;
}
sourcePermanent.sacrifice(source, game);
game.addEffect(new GainAbilityTargetEffect(IndestructibleAbility.getInstance())
.setTargetPointer(new FixedTarget(enchantedPermanent, game)), source);
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DESTROY_PERMANENT;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
return sourcePermanent != null && event.getTargetId().equals(sourcePermanent.getAttachedTo());
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public CracklingEmergenceEffect copy() {
return new CracklingEmergenceEffect(this);
}
}

View file

@ -67,6 +67,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet {
cards.add(new SetCardInfo("Colossal Skyturtle", 216, Rarity.UNCOMMON, mage.cards.c.ColossalSkyturtle.class));
cards.add(new SetCardInfo("Commune with Spirits", 180, Rarity.COMMON, mage.cards.c.CommuneWithSpirits.class));
cards.add(new SetCardInfo("Covert Technician", 49, Rarity.UNCOMMON, mage.cards.c.CovertTechnician.class));
cards.add(new SetCardInfo("Crackling Emergence", 136, Rarity.COMMON, mage.cards.c.CracklingEmergence.class));
cards.add(new SetCardInfo("Debt to the Kami", 92, Rarity.COMMON, mage.cards.d.DebtToTheKami.class));
cards.add(new SetCardInfo("Dismal Backwater", 267, Rarity.COMMON, mage.cards.d.DismalBackwater.class));
cards.add(new SetCardInfo("Disruption Protocol", 51, Rarity.COMMON, mage.cards.d.DisruptionProtocol.class));

View file

@ -1,5 +1,3 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
@ -24,16 +22,17 @@ import mage.game.permanent.Permanent;
*/
public class TotemArmorAbility extends SimpleStaticAbility {
public TotemArmorAbility() {
super(Zone.BATTLEFIELD, new TotemArmorEffect());
}
public TotemArmorAbility(final TotemArmorAbility ability) {
private TotemArmorAbility(final TotemArmorAbility ability) {
super(ability);
}
@Override
public SimpleStaticAbility copy() {
public TotemArmorAbility copy() {
return new TotemArmorAbility(this);
}
@ -44,27 +43,27 @@ public class TotemArmorAbility extends SimpleStaticAbility {
}
class TotemArmorEffect extends ReplacementEffectImpl {
TotemArmorEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
}
TotemArmorEffect(final TotemArmorEffect effect) {
private TotemArmorEffect(final TotemArmorEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
Permanent equipedPermanent = game.getPermanent(event.getTargetId());
if (equipedPermanent != null) {
equipedPermanent.removeAllDamage(game);
sourcePermanent.destroy(source, game, false);
return true;
}
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
Permanent enchantedPermanent = game.getPermanent(event.getTargetId());
if (sourcePermanent == null || enchantedPermanent == null) {
return false;
}
return false;
enchantedPermanent.removeAllDamage(game);
sourcePermanent.destroy(source, game, false);
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DESTROY_PERMANENT;
@ -72,7 +71,7 @@ class TotemArmorEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
return sourcePermanent != null && event.getTargetId().equals(sourcePermanent.getAttachedTo());
}