From 7efbccd7d55f41342eb4c73206cbed1caacba77c Mon Sep 17 00:00:00 2001 From: jimga150 Date: Sat, 6 Jan 2024 15:09:47 -0500 Subject: [PATCH] [LCC] Implement Sunfrill Imitator (#11591) --- .../src/mage/cards/s/SunfrillImitator.java | 109 ++++++++++++++++++ .../sets/LostCavernsOfIxalanCommander.java | 1 + 2 files changed, 110 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SunfrillImitator.java diff --git a/Mage.Sets/src/mage/cards/s/SunfrillImitator.java b/Mage.Sets/src/mage/cards/s/SunfrillImitator.java new file mode 100644 index 00000000000..7a383e04b83 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SunfrillImitator.java @@ -0,0 +1,109 @@ +package mage.cards.s; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.constants.*; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.common.TargetControlledPermanent; +import mage.util.functions.CopyApplier; + +/** + * + * @author jimga150 + */ +public final class SunfrillImitator extends CardImpl { + + public SunfrillImitator(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); + + this.subtype.add(SubType.DINOSAUR); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Whenever Sunfrill Imitator attacks, you may have it become a copy of another target Dinosaur you control, + // except its name is Sunfrill Imitator and it has this ability. + this.addAbility(new SunfrillImitatorAbility()); + } + + private SunfrillImitator(final SunfrillImitator card) { + super(card); + } + + @Override + public SunfrillImitator copy() { + return new SunfrillImitator(this); + } +} + +class SunfrillImitatorAbility extends AttacksTriggeredAbility { + + private static final FilterControlledPermanent dino_filter = new FilterControlledPermanent(SubType.DINOSAUR, "Dinosaur"); + + static { + dino_filter.add(AnotherPredicate.instance); + } + + public SunfrillImitatorAbility() { + super(new SunfrillImitatorEffect(), true); + this.addTarget(new TargetControlledPermanent(dino_filter)); + } + + private SunfrillImitatorAbility(final SunfrillImitatorAbility ability) { + super(ability); + } + + @Override + public SunfrillImitatorAbility copy() { + return new SunfrillImitatorAbility(this); + } +} + +class SunfrillImitatorEffect extends OneShotEffect { + + private static final CopyApplier copyApplier = new CopyApplier() { + @Override + public boolean apply(Game game, MageObject blueprint, Ability source, UUID targetObjectId) { + blueprint.setName("Sunfrill Imitator"); + // Permanent also keeps this copy ability + blueprint.getAbilities().add(new SunfrillImitatorAbility()); + return true; + } + }; + + public SunfrillImitatorEffect() { + super(Outcome.Benefit); + staticText = "you may have it become a copy of another target Dinosaur you control, " + + "except its name is Sunfrill Imitator and it has this ability."; + } + + private SunfrillImitatorEffect(final SunfrillImitatorEffect effect) { + super(effect); + } + + // The following is based on Identity Thief and Cephalid Facetaker + @Override + public boolean apply(Game game, Ability source) { + Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (targetPermanent != null && sourcePermanent != null) { + game.copyPermanent(Duration.EndOfGame, targetPermanent, sourcePermanent.getId(), source, copyApplier); + return true; + } + return false; + } + + @Override + public SunfrillImitatorEffect copy() { + return new SunfrillImitatorEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/LostCavernsOfIxalanCommander.java b/Mage.Sets/src/mage/sets/LostCavernsOfIxalanCommander.java index 98cfb08d3e7..f1c4a9ddf1d 100644 --- a/Mage.Sets/src/mage/sets/LostCavernsOfIxalanCommander.java +++ b/Mage.Sets/src/mage/sets/LostCavernsOfIxalanCommander.java @@ -253,6 +253,7 @@ public final class LostCavernsOfIxalanCommander extends ExpansionSet { cards.add(new SetCardInfo("Storm Fleet Negotiator", 78, Rarity.RARE, mage.cards.s.StormFleetNegotiator.class)); cards.add(new SetCardInfo("Strionic Resonator", 116, Rarity.RARE, mage.cards.s.StrionicResonator.class)); cards.add(new SetCardInfo("Sulfur Falls", 354, Rarity.RARE, mage.cards.s.SulfurFalls.class)); + cards.add(new SetCardInfo("Sunfrill Imitator", 94, Rarity.RARE, mage.cards.s.SunfrillImitator.class)); cards.add(new SetCardInfo("Sunken Hollow", 355, Rarity.RARE, mage.cards.s.SunkenHollow.class)); cards.add(new SetCardInfo("Surgespanner", 174, Rarity.RARE, mage.cards.s.Surgespanner.class)); cards.add(new SetCardInfo("Svyelun of Sea and Sky", 175, Rarity.MYTHIC, mage.cards.s.SvyelunOfSeaAndSky.class));