From 86fb55fe1ec9857a39592082753a66e5456b02ad Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 15 Sep 2018 12:53:58 -0400 Subject: [PATCH] Implemented Mission Briefing --- .../src/mage/cards/m/MissionBriefing.java | 164 ++++++++++++++++++ Mage.Sets/src/mage/sets/GuildsOfRavnica.java | 1 + 2 files changed, 165 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MissionBriefing.java diff --git a/Mage.Sets/src/mage/cards/m/MissionBriefing.java b/Mage.Sets/src/mage/cards/m/MissionBriefing.java new file mode 100644 index 0000000000..5441494130 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MissionBriefing.java @@ -0,0 +1,164 @@ +package mage.cards.m; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterInstantOrSorceryCard; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author TheElk801 + */ +public final class MissionBriefing extends CardImpl { + + public MissionBriefing(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}{U}"); + + // Surveil 2, then choose an instant or sorcery card in your graveyard. You may cast that card this turn. If that card would be put into your graveyard this turn, exile it instead. + this.getSpellAbility().addEffect(new MissionBriefingEffect()); + } + + public MissionBriefing(final MissionBriefing card) { + super(card); + } + + @Override + public MissionBriefing copy() { + return new MissionBriefing(this); + } +} + +class MissionBriefingEffect extends OneShotEffect { + + public static final FilterCard filter = new FilterInstantOrSorceryCard("instant or sorcery card from your graveyard"); + + public MissionBriefingEffect() { + super(Outcome.Benefit); + this.staticText = "Surveil 2, then choose an instant or sorcery card " + + "in your graveyard. You may cast that card this turn. " + + "If that card would be put into your graveyard this turn, " + + "exile it instead."; + } + + public MissionBriefingEffect(final MissionBriefingEffect effect) { + super(effect); + } + + @Override + public MissionBriefingEffect copy() { + return new MissionBriefingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Target target = new TargetCardInYourGraveyard(filter); + if (!player.choose(outcome, target, source.getSourceId(), game)) { + return false; + } + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + ContinuousEffect effect = new MissionBriefingCastFromGraveyardEffect(); + effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + game.addEffect(effect, source); + effect = new MissionBriefingReplacementEffect(card.getId()); + game.addEffect(effect, source); + return true; + } + return false; + } +} + +class MissionBriefingCastFromGraveyardEffect extends AsThoughEffectImpl { + + public MissionBriefingCastFromGraveyardEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit); + } + + public MissionBriefingCastFromGraveyardEffect(final MissionBriefingCastFromGraveyardEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public MissionBriefingCastFromGraveyardEffect copy() { + return new MissionBriefingCastFromGraveyardEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + return objectId.equals(this.getTargetPointer().getFirst(game, source)) + && affectedControllerId.equals(source.getControllerId()); + } +} + +class MissionBriefingReplacementEffect extends ReplacementEffectImpl { + + private final UUID cardId; + + public MissionBriefingReplacementEffect(UUID cardId) { + super(Duration.EndOfTurn, Outcome.Exile); + this.cardId = cardId; + staticText = "If that card would be put into your graveyard this turn, " + + "exile it instead"; + } + + public MissionBriefingReplacementEffect(final MissionBriefingReplacementEffect effect) { + super(effect); + this.cardId = effect.cardId; + } + + @Override + public MissionBriefingReplacementEffect copy() { + return new MissionBriefingReplacementEffect(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getCard(this.cardId); + if (controller != null && card != null) { + controller.moveCardsToExile(card, source, game, true, null, ""); + return true; + } + return false; + } + + @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) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + return zEvent.getToZone() == Zone.GRAVEYARD + && zEvent.getTargetId().equals(this.cardId); + } +} diff --git a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java index 6279463cb3..fdff85f480 100644 --- a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java +++ b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java @@ -112,6 +112,7 @@ public final class GuildsOfRavnica extends ExpansionSet { cards.add(new SetCardInfo("Maximize Altitude", 43, Rarity.COMMON, mage.cards.m.MaximizeAltitude.class)); cards.add(new SetCardInfo("Maximize Velocity", 111, Rarity.COMMON, mage.cards.m.MaximizeVelocity.class)); cards.add(new SetCardInfo("Midnight Reaper", 77, Rarity.RARE, mage.cards.m.MidnightReaper.class)); + cards.add(new SetCardInfo("Mission Briefing", 44, Rarity.RARE, mage.cards.m.MissionBriefing.class)); cards.add(new SetCardInfo("Molderhulk", 190, Rarity.UNCOMMON, mage.cards.m.Molderhulk.class)); cards.add(new SetCardInfo("Moodmark Painter", 78, Rarity.COMMON, mage.cards.m.MoodmarkPainter.class)); cards.add(new SetCardInfo("Mountain", 263, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));