From b14d7d24bbe1e2cb29bf4eb7171f743ba143e331 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 30 Aug 2022 20:50:26 -0400 Subject: [PATCH] [DMU] Implemented Yotia Declares War --- .../src/mage/cards/y/YotiaDeclaresWar.java | 124 ++++++++++++++++++ Mage.Sets/src/mage/sets/DominariaUnited.java | 1 + .../permanent/token/OrnithopterToken.java | 36 +++++ 3 files changed, 161 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/y/YotiaDeclaresWar.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/OrnithopterToken.java diff --git a/Mage.Sets/src/mage/cards/y/YotiaDeclaresWar.java b/Mage.Sets/src/mage/cards/y/YotiaDeclaresWar.java new file mode 100644 index 0000000000..ad36b3a804 --- /dev/null +++ b/Mage.Sets/src/mage/cards/y/YotiaDeclaresWar.java @@ -0,0 +1,124 @@ +package mage.cards.y; + +import mage.abilities.Ability; +import mage.abilities.common.SagaAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.effects.Effects; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.continuous.AddCardTypeTargetEffect; +import mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledArtifactPermanent; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.OrnithopterToken; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreatureOrPlaneswalker; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class YotiaDeclaresWar extends CardImpl { + + public YotiaDeclaresWar(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}"); + + this.subtype.add(SubType.SAGA); + + // Read ahead + SagaAbility sagaAbility = new SagaAbility(this, SagaChapter.CHAPTER_III, true); + + // I -- Create a 0/2 colorless Thopter artifact creature token with flying named Ornithopter. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_I, new CreateTokenEffect(new OrnithopterToken())); + + // II -- Tap any number of untapped artifacts you control. When you do, Yotia Declares War deals that much damage to target creature or planeswalker. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_II, new YotiaDeclaresWarEffect()); + + // III -- Up to one target artifact you control becomes an artifact creature with base power and toughness 4/4 until end of turn. + sagaAbility.addChapterEffect( + this, SagaChapter.CHAPTER_III, SagaChapter.CHAPTER_III, + new Effects( + new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT, CardType.CREATURE) + .setText("p to one target artifact you control becomes an artifact creature"), + new SetPowerToughnessTargetEffect(5, 5, Duration.EndOfTurn) + .setText("with base power and toughness 4/4 until end of turn") + ), new TargetPermanent(0, 1, StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT) + ); + this.addAbility(sagaAbility); + } + + private YotiaDeclaresWar(final YotiaDeclaresWar card) { + super(card); + } + + @Override + public YotiaDeclaresWar copy() { + return new YotiaDeclaresWar(this); + } +} + +class YotiaDeclaresWarEffect extends OneShotEffect { + + private static final FilterPermanent filter + = new FilterControlledArtifactPermanent("untapped artifacts you control"); + + static { + filter.add(TappedPredicate.UNTAPPED); + } + + YotiaDeclaresWarEffect() { + super(Outcome.Benefit); + staticText = "tap any number of untapped artifacts you control. " + + "When you do, {this} deals that much damage to target creature or planeswalker"; + } + + private YotiaDeclaresWarEffect(final YotiaDeclaresWarEffect effect) { + super(effect); + } + + @Override + public YotiaDeclaresWarEffect copy() { + return new YotiaDeclaresWarEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); + player.choose(outcome, target, source, game); + List permanents = target + .getTargets() + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + if (permanents.isEmpty()) { + return false; + } + for (Permanent permanent:permanents){ + permanent.tap(source, game); + } + ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility( + new DamageTargetEffect(permanents.size()), false + ); + ability.addTarget(new TargetCreatureOrPlaneswalker()); + game.fireReflexiveTriggeredAbility(ability, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index 1fa2e22120..eff6890e7d 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -255,6 +255,7 @@ public final class DominariaUnited extends ExpansionSet { cards.add(new SetCardInfo("Yavimaya Iconoclast", 190, Rarity.UNCOMMON, mage.cards.y.YavimayaIconoclast.class)); cards.add(new SetCardInfo("Yavimaya Sojourner", 191, Rarity.COMMON, mage.cards.y.YavimayaSojourner.class)); cards.add(new SetCardInfo("Yavimaya Steelcrusher", 152, Rarity.COMMON, mage.cards.y.YavimayaSteelcrusher.class)); + cards.add(new SetCardInfo("Yotia Declares War", 153, Rarity.UNCOMMON, mage.cards.y.YotiaDeclaresWar.class)); cards.add(new SetCardInfo("Zar Ojanen, Scion of Efrava", 227, Rarity.UNCOMMON, mage.cards.z.ZarOjanenScionOfEfrava.class)); } diff --git a/Mage/src/main/java/mage/game/permanent/token/OrnithopterToken.java b/Mage/src/main/java/mage/game/permanent/token/OrnithopterToken.java new file mode 100644 index 0000000000..39d0efc7d8 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/OrnithopterToken.java @@ -0,0 +1,36 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.keyword.FlyingAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.Arrays; + +/** + * @author TheElk801 + */ +public final class OrnithopterToken extends TokenImpl { + + public OrnithopterToken() { + super("Ornithopter", "0/2 colorless Thopter artifact creature token with flying named Ornithopter"); + cardType.add(CardType.ARTIFACT); + cardType.add(CardType.CREATURE); + subtype.add(SubType.THOPTER); + power = new MageInt(0); + toughness = new MageInt(2); + + addAbility(FlyingAbility.getInstance()); + + availableImageSetCodes = Arrays.asList("DMU"); + } + + public OrnithopterToken(final OrnithopterToken token) { + super(token); + } + + @Override + public OrnithopterToken copy() { + return new OrnithopterToken(this); + } +}