From 0bb56e99fdb95685239e86644aff5e9787109fb6 Mon Sep 17 00:00:00 2001 From: theelk801 <theelk801@gmail.com> Date: Tue, 25 Apr 2023 08:28:39 -0400 Subject: [PATCH] [J22] Implement Pirated Copy --- Mage.Sets/src/mage/cards/p/PiratedCopy.java | 85 +++++++++++++++++++++ Mage.Sets/src/mage/sets/Jumpstart2022.java | 1 + 2 files changed, 86 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PiratedCopy.java diff --git a/Mage.Sets/src/mage/cards/p/PiratedCopy.java b/Mage.Sets/src/mage/cards/p/PiratedCopy.java new file mode 100644 index 0000000000..fcdabe53f8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PiratedCopy.java @@ -0,0 +1,85 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.effects.common.CopyPermanentEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SetTargetPointer; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.game.Game; +import mage.util.CardUtil; +import mage.util.functions.CopyApplier; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PiratedCopy extends CardImpl { + + private static final FilterPermanent filter + = new FilterPermanent("this creature or another creature with the same name"); + + static { + filter.add(PiratedCopyPredicate.instance); + } + + private static final CopyApplier applier = new CopyApplier() { + @Override + public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) { + blueprint.addSubType(SubType.PIRATE); + blueprint.getAbilities().add(new DealsDamageToAPlayerAllTriggeredAbility( + new DrawCardSourceControllerEffect(1), filter, + true, SetTargetPointer.NONE, true + )); + return true; + } + + @Override + public String toString() { + return ", except it's a Pirate in addition to its other types and it has \"Whenever this creature " + + "or another creature with the same name deals combat damage to a player, you may draw a card.\""; + } + }; + + public PiratedCopy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}"); + + this.subtype.add(SubType.SHAPESHIFTER); + this.subtype.add(SubType.PIRATE); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // You may have Pirated Copy enter the battlefield as a copy of any creature on the battlefield, except it's a Pirate in addition to its other types and it has "Whenever this creature or another creature with the same name deals combat damage to a player, you may draw a card." + this.addAbility(new EntersBattlefieldAbility(new CopyPermanentEffect(applier), true)); + } + + private PiratedCopy(final PiratedCopy card) { + super(card); + } + + @Override + public PiratedCopy copy() { + return new PiratedCopy(this); + } +} + +enum PiratedCopyPredicate implements ObjectSourcePlayerPredicate<MageObject> { + instance; + + @Override + public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) { + return !AnotherPredicate.instance.apply(input, game) + || (input.getObject().isCreature(game) && CardUtil.haveSameNames(input.getObject(), input.getSource().getSourcePermanentOrLKI(game))); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Jumpstart2022.java b/Mage.Sets/src/mage/sets/Jumpstart2022.java index 3bb6fc0050..caba26d3c0 100644 --- a/Mage.Sets/src/mage/sets/Jumpstart2022.java +++ b/Mage.Sets/src/mage/sets/Jumpstart2022.java @@ -548,6 +548,7 @@ public final class Jumpstart2022 extends ExpansionSet { cards.add(new SetCardInfo("Pillardrop Rescuer", 226, Rarity.COMMON, mage.cards.p.PillardropRescuer.class)); cards.add(new SetCardInfo("Pious Wayfarer", 227, Rarity.COMMON, mage.cards.p.PiousWayfarer.class)); cards.add(new SetCardInfo("Piranha Marsh", 818, Rarity.COMMON, mage.cards.p.PiranhaMarsh.class)); + cards.add(new SetCardInfo("Pirated Copy", 16, Rarity.MYTHIC, mage.cards.p.PiratedCopy.class)); cards.add(new SetCardInfo("Pit Keeper", 455, Rarity.COMMON, mage.cards.p.PitKeeper.class)); cards.add(new SetCardInfo("Plague Spitter", 456, Rarity.UNCOMMON, mage.cards.p.PlagueSpitter.class)); cards.add(new SetCardInfo("Plaguecrafter", 72, Rarity.UNCOMMON, mage.cards.p.Plaguecrafter.class));