diff --git a/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java b/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java new file mode 100644 index 0000000000..3a158f7778 --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java @@ -0,0 +1,87 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterPermanentCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AcolyteOfAffliction extends CardImpl { + + public AcolyteOfAffliction(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.CLERIC); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // When Acolyte of Affliction enters the battlefield, put the top two cards of your library into your graveyard, then you may return a permanent card from your graveyard to your hand. + this.addAbility(new EntersBattlefieldTriggeredAbility(new AcolyteOfAfflictionEffect())); + } + + private AcolyteOfAffliction(final AcolyteOfAffliction card) { + super(card); + } + + @Override + public AcolyteOfAffliction copy() { + return new AcolyteOfAffliction(this); + } +} + +class AcolyteOfAfflictionEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterPermanentCard("permanent card from your graveyard"); + + AcolyteOfAfflictionEffect() { + super(Outcome.Benefit); + staticText = "put the top two cards of your library into your graveyard, " + + "then you may return a permanent card from your graveyard to your hand."; + } + + private AcolyteOfAfflictionEffect(final AcolyteOfAfflictionEffect effect) { + super(effect); + } + + @Override + public AcolyteOfAfflictionEffect copy() { + return new AcolyteOfAfflictionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + player.moveCards(player.getLibrary().getTopCards(game, 2), Zone.GRAVEYARD, source, game); + TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true); + if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + return true; + } + Card card = game.getCard(target.getFirstTarget()); + if (card == null) { + return true; + } + player.moveCards(card, Zone.HAND, source, game); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/c/ChainToMemory.java b/Mage.Sets/src/mage/cards/c/ChainToMemory.java index 51b9815132..9a58196956 100644 --- a/Mage.Sets/src/mage/cards/c/ChainToMemory.java +++ b/Mage.Sets/src/mage/cards/c/ChainToMemory.java @@ -18,7 +18,7 @@ public final class ChainToMemory extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}"); // Target creature gets -4/-0 until end of turn. Scry 2. - this.getSpellAbility().addEffect(new BoostTargetEffect(-2, 0)); + this.getSpellAbility().addEffect(new BoostTargetEffect(-4, 0)); this.getSpellAbility().addEffect(new ScryEffect(2).setText("Scry 2")); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } diff --git a/Mage.Sets/src/mage/cards/m/MedomaisProphecy.java b/Mage.Sets/src/mage/cards/m/MedomaisProphecy.java new file mode 100644 index 0000000000..0ef942dc93 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MedomaisProphecy.java @@ -0,0 +1,154 @@ +package mage.cards.m; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.common.SagaAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ChooseACardNameEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.keyword.ScryEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.players.Player; + +import java.util.UUID; + +import static mage.abilities.effects.common.ChooseACardNameEffect.TypeOfName.ALL; + +/** + * @author TheElk801 + */ +public final class MedomaisProphecy extends CardImpl { + + public MedomaisProphecy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); + + this.subtype.add(SubType.SAGA); + + // (As this Saga enters and after your draw step, add a lore counter. Sacrifice after IV.) + SagaAbility sagaAbility = new SagaAbility(this, SagaChapter.CHAPTER_IV); + + // I — Scry 2. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_I, new ScryEffect(2)); + + // II — Choose a card name. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_II, new ChooseACardNameEffect(ALL)); + + // III — When you cast a spell with the chosen card name for the first time this turn, draw two cards. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_III, new MedomaisProphecyTriggerEffect()); + + // IV — Look at the top card of each player's library. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_IV, new MedomaisProphecyLookEffect()); + } + + private MedomaisProphecy(final MedomaisProphecy card) { + super(card); + } + + @Override + public MedomaisProphecy copy() { + return new MedomaisProphecy(this); + } +} + +class MedomaisProphecyTriggerEffect extends OneShotEffect { + + MedomaisProphecyTriggerEffect() { + super(Outcome.Benefit); + staticText = "When you cast a spell with the chosen card name for the first time this turn, draw two cards."; + } + + private MedomaisProphecyTriggerEffect(final MedomaisProphecyTriggerEffect effect) { + super(effect); + } + + @Override + public MedomaisProphecyTriggerEffect copy() { + return new MedomaisProphecyTriggerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + String cardName = (String) game.getState().getValue( + source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY + ); + if (cardName == null || "".equals(cardName)) { + return false; + } + game.addDelayedTriggeredAbility(new MedomaisProphecyDelayedTriggeredAbility(cardName), source); + return true; + } +} + +class MedomaisProphecyDelayedTriggeredAbility extends DelayedTriggeredAbility { + private final String spellName; + + MedomaisProphecyDelayedTriggeredAbility(String spellName) { + super(new DrawCardSourceControllerEffect(2), Duration.EndOfTurn, true, false); + this.spellName = spellName; + } + + private MedomaisProphecyDelayedTriggeredAbility(final MedomaisProphecyDelayedTriggeredAbility ability) { + super(ability); + this.spellName = ability.spellName; + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!event.getPlayerId().equals(this.getControllerId())) { + return false; + } + Spell spell = game.getStack().getSpell(event.getTargetId()); + return spell != null && spellName.equals(spell.getName()); + } + + @Override + public MedomaisProphecyDelayedTriggeredAbility copy() { + return new MedomaisProphecyDelayedTriggeredAbility(this); + } +} + +class MedomaisProphecyLookEffect extends OneShotEffect { + + MedomaisProphecyLookEffect() { + super(Outcome.Benefit); + staticText = "look at the top card of each player's library"; + } + + private MedomaisProphecyLookEffect(final MedomaisProphecyLookEffect effect) { + super(effect); + } + + @Override + public MedomaisProphecyLookEffect copy() { + return new MedomaisProphecyLookEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourcePermanentOrLKI(game); + if (controller == null || sourceObject == null) { + return false; + } + game.getState() + .getPlayersInRange(source.getControllerId(), game) + .stream() + .map(game::getPlayer) + .map(Player::getLibrary) + .forEachOrdered(library -> controller.lookAtCards( + sourceObject.getIdName(), library.getFromTop(game), game + )); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index d84e1c5228..836ab306e7 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -26,6 +26,7 @@ public final class TherosBeyondDeath extends ExpansionSet { this.ratioBoosterMythic = 8; this.maxCardNumberInBooster = 254; + cards.add(new SetCardInfo("Acolyte of Affliction", 206, Rarity.UNCOMMON, mage.cards.a.AcolyteOfAffliction.class)); cards.add(new SetCardInfo("Allure of the Unknown", 207, Rarity.RARE, mage.cards.a.AllureOfTheUnknown.class)); cards.add(new SetCardInfo("Alseid of Life's Bounty", 1, Rarity.UNCOMMON, mage.cards.a.AlseidOfLifesBounty.class)); cards.add(new SetCardInfo("Altar of the Pantheon", 231, Rarity.COMMON, mage.cards.a.AltarOfThePantheon.class)); @@ -135,6 +136,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Leonin of the Lost Pride", 28, Rarity.COMMON, mage.cards.l.LeoninOfTheLostPride.class)); cards.add(new SetCardInfo("Loathsome Chimera", 177, Rarity.COMMON, mage.cards.l.LoathsomeChimera.class)); cards.add(new SetCardInfo("Mantle of the Wolf", 178, Rarity.RARE, mage.cards.m.MantleOfTheWolf.class)); + cards.add(new SetCardInfo("Medomai's Prophecy", 53, Rarity.UNCOMMON, mage.cards.m.MedomaisProphecy.class)); cards.add(new SetCardInfo("Memory Drain", 54, Rarity.COMMON, mage.cards.m.MemoryDrain.class)); cards.add(new SetCardInfo("Mindwrack Harpy", 276, Rarity.COMMON, mage.cards.m.MindwrackHarpy.class)); cards.add(new SetCardInfo("Mire Triton", 105, Rarity.UNCOMMON, mage.cards.m.MireTriton.class));