From d1023be26291973217e4092ba0a937b3c9183ca4 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Sat, 25 May 2024 19:35:37 +0200 Subject: [PATCH] implement [MH3] Emperor of Bones --- .../src/mage/cards/e/EmperorOfBones.java | 118 ++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons3.java | 1 + 2 files changed, 119 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/EmperorOfBones.java diff --git a/Mage.Sets/src/mage/cards/e/EmperorOfBones.java b/Mage.Sets/src/mage/cards/e/EmperorOfBones.java new file mode 100644 index 00000000000..4f4db61c3af --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EmperorOfBones.java @@ -0,0 +1,118 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.common.OneOrMoreCountersAddedTriggeredAbility; +import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.abilities.effects.common.SacrificeTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.AdaptAbility; +import mage.abilities.keyword.HasteAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.counters.Counters; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; +import mage.target.common.TargetCardInGraveyard; +import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class EmperorOfBones extends CardImpl { + + public EmperorOfBones(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); + + this.subtype.add(SubType.SKELETON); + this.subtype.add(SubType.NOBLE); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // At the beginning of combat on your turn, exile up to one target card from a graveyard. + Ability ability = new BeginningOfCombatTriggeredAbility( + new ExileTargetEffect().setToSourceExileZone(true), + TargetController.YOU, false + ); + ability.addTarget(new TargetCardInGraveyard(0, 1)); + this.addAbility(ability); + + // {1}{B}: Adapt 2. + this.addAbility(new AdaptAbility(2, "{1}{B}")); + + // Whenever one or more +1/+1 counters are put on Emperor of Bones, put a creature card exiled with Emperor of Bones onto the battlefield under your control with a finality counter on it. It gains haste. Sacrifice it at the beginning of the next end step. + this.addAbility(new OneOrMoreCountersAddedTriggeredAbility(new EmperorOfBonesEffect())); + } + + private EmperorOfBones(final EmperorOfBones card) { + super(card); + } + + @Override + public EmperorOfBones copy() { + return new EmperorOfBones(this); + } +} + +class EmperorOfBonesEffect extends OneShotEffect { + + EmperorOfBonesEffect() { + super(Outcome.PutCreatureInPlay); + staticText = "put a creature card exiled with {this} onto the battlefield under your control with a finality counter on it. " + + "It gains haste. Sacrifice it at the beginning of the next end step"; + } + + private EmperorOfBonesEffect(final EmperorOfBonesEffect effect) { + super(effect); + } + + @Override + public EmperorOfBonesEffect copy() { + return new EmperorOfBonesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetCard target = new TargetCardInExile( + 1, 1, + StaticFilters.FILTER_CARD_CREATURE, + CardUtil.getExileZoneId(game, source) + ); + player.choose(outcome, target, source, game); + Card card = game.getCard(target.getFirstTarget()); + if (card == null) { + return true; + } + game.setEnterWithCounters(card.getId(), new Counters().addCounter(CounterType.FINALITY.createInstance())); + player.moveCards(card, Zone.BATTLEFIELD, source, game); + Permanent permanent = game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId()); + if (permanent == null) { + return true; + } + game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfGame) + .setTargetPointer(new FixedTarget(permanent, game)), source); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new SacrificeTargetEffect("sacrifice it") + .setTargetPointer(new FixedTarget(permanent, game)), + TargetController.ANY + ), source); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index b09947cb937..d2eac26e359 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -50,6 +50,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Eladamri, Korvecdal", 149, Rarity.MYTHIC, mage.cards.e.EladamriKorvecdal.class)); cards.add(new SetCardInfo("Eldrazi Ravager", 5, Rarity.UNCOMMON, mage.cards.e.EldraziRavager.class)); cards.add(new SetCardInfo("Emerald Medallion", 291, Rarity.RARE, mage.cards.e.EmeraldMedallion.class)); + cards.add(new SetCardInfo("Emperor of Bones", 90, Rarity.RARE, mage.cards.e.EmperorOfBones.class)); cards.add(new SetCardInfo("Emrakul's Messenger", 61, Rarity.UNCOMMON, mage.cards.e.EmrakulsMessenger.class)); cards.add(new SetCardInfo("Emrakul, the World Anew", 6, Rarity.MYTHIC, mage.cards.e.EmrakulTheWorldAnew.class)); cards.add(new SetCardInfo("Estrid's Invocation", 269, Rarity.RARE, mage.cards.e.EstridsInvocation.class));