[MID] Implemented Can't Stay Away

This commit is contained in:
Daniel Bomar 2021-09-05 19:36:40 -05:00
parent 4716af75d6
commit bccf56a988
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 130 additions and 0 deletions

View file

@ -0,0 +1,129 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author weirddan455
*/
public final class CantStayAway extends CardImpl {
private static final FilterCreatureCard filter = new FilterCreatureCard("creature card with mana value 3 or less from your graveyard");
static {
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4));
}
public CantStayAway(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}{B}");
// Return target creature card with mana value 3 or less from your graveyard to the battlefield. It gains "If this creature would die, exile it instead."
this.getSpellAbility().addEffect(new CantStayAwayEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(filter));
// Flashback {3}{W}{B}
this.addAbility(new FlashbackAbility(new ManaCostsImpl<>("{3}{W}{B}"), TimingRule.SORCERY));
}
private CantStayAway(final CantStayAway card) {
super(card);
}
@Override
public CantStayAway copy() {
return new CantStayAway(this);
}
}
class CantStayAwayEffect extends OneShotEffect {
public CantStayAwayEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Return target creature card with mana value 3 or less from your graveyard to the battlefield. It gains \"If this creature would die, exile it instead.\"";
}
private CantStayAwayEffect(final CantStayAwayEffect effect) {
super(effect);
}
@Override
public CantStayAwayEffect copy() {
return new CantStayAwayEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card targetCard = game.getCard(source.getFirstTarget());
if (controller == null || targetCard == null) {
return false;
}
controller.moveCards(targetCard, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(targetCard.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(new SimpleStaticAbility(new CantStayAwayReplacementEffect()), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return true;
}
}
class CantStayAwayReplacementEffect extends ReplacementEffectImpl {
public CantStayAwayReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Exile);
staticText = "If {this} would die, exile it instead";
}
private CantStayAwayReplacementEffect(final CantStayAwayReplacementEffect effect) {
super(effect);
}
@Override
public CantStayAwayReplacementEffect copy() {
return new CantStayAwayReplacementEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) {
ZoneChangeEvent zce = (ZoneChangeEvent) event;
return zce.isDiesEvent();
}
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
return false;
}
}

View file

@ -33,6 +33,7 @@ public final class InnistradMidnightHunt extends ExpansionSet {
cards.add(new SetCardInfo("Arrogant Outlaw", 84, Rarity.COMMON, mage.cards.a.ArrogantOutlaw.class));
cards.add(new SetCardInfo("Bladestitched Skaab", 212, Rarity.UNCOMMON, mage.cards.b.BladestitchedSkaab.class));
cards.add(new SetCardInfo("Can't Stay Away", 368, Rarity.RARE, mage.cards.c.CantStayAway.class));
cards.add(new SetCardInfo("Candlelit Cavalry", 175, Rarity.COMMON, mage.cards.c.CandlelitCavalry.class));
cards.add(new SetCardInfo("Champion of the Perished", 91, Rarity.RARE, mage.cards.c.ChampionOfThePerished.class));
cards.add(new SetCardInfo("Clear Shot", 176, Rarity.UNCOMMON, mage.cards.c.ClearShot.class));