From adfaa74fadb4ab0b9ef07f72af3db684a9842635 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 13 Oct 2022 20:02:38 -0400 Subject: [PATCH] [BOT] Implemented Ratchet, Field Medic / Ratcher, Rescue Racer --- .../src/mage/cards/r/RatchetFieldMedic.java | 115 ++++++++++++++++++ .../src/mage/cards/r/RatchetRescueRacer.java | 61 ++++++++++ Mage.Sets/src/mage/sets/Transformers.java | 2 + 3 files changed, 178 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RatchetFieldMedic.java create mode 100644 Mage.Sets/src/mage/cards/r/RatchetRescueRacer.java diff --git a/Mage.Sets/src/mage/cards/r/RatchetFieldMedic.java b/Mage.Sets/src/mage/cards/r/RatchetFieldMedic.java new file mode 100644 index 00000000000..ef86bf71e43 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RatchetFieldMedic.java @@ -0,0 +1,115 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.GainLifeControllerTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; +import mage.abilities.keyword.LifelinkAbility; +import mage.abilities.keyword.MoreThanMeetsTheEyeAbility; +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.SuperType; +import mage.filter.FilterCard; +import mage.filter.common.FilterArtifactCard; +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCardInYourGraveyard; +import mage.watchers.common.PlayerGainedLifeWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RatchetFieldMedic extends CardImpl { + + public RatchetFieldMedic(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ROBOT); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + this.secondSideCardClazz = mage.cards.r.RatchetRescueRacer.class; + + // More Than Meets the Eye {1}{W} + this.addAbility(new MoreThanMeetsTheEyeAbility(this, "{1}{W}")); + + // Lifelink + this.addAbility(LifelinkAbility.getInstance()); + + // Whenever you gain life, you may convert Ratchet. When you do, return target artifact card with mana value less than or equal to the amount of life you gained this turn from your graveyard to the battlefield tapped. + this.addAbility(new GainLifeControllerTriggeredAbility( + new RatchetFieldMedicEffect(), true + ), new PlayerGainedLifeWatcher()); + } + + private RatchetFieldMedic(final RatchetFieldMedic card) { + super(card); + } + + @Override + public RatchetFieldMedic copy() { + return new RatchetFieldMedic(this); + } +} + +class RatchetFieldMedicEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterArtifactCard("artifact card with mana value " + + "less than or equal to the amount of life you gained this turn from your graveyard"); + + static { + filter.add(RatchetFieldMedicPredicate.instance); + } + + RatchetFieldMedicEffect() { + super(Outcome.Benefit); + staticText = "convert {this}. When you do, return target artifact card with mana value less than or equal to the amount of life you gained this turn from your graveyard to the battlefield tapped"; + } + + private RatchetFieldMedicEffect(final RatchetFieldMedicEffect effect) { + super(effect); + } + + @Override + public RatchetFieldMedicEffect copy() { + return new RatchetFieldMedicEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + // check not to transform twice the same side + if (permanent == null || !permanent.transform(source, game)) { + return false; + } + ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility( + new ReturnFromGraveyardToBattlefieldTargetEffect(true), false + ); + ability.addTarget(new TargetCardInYourGraveyard(filter)); + game.fireReflexiveTriggeredAbility(ability, source); + return true; + } +} + +enum RatchetFieldMedicPredicate implements Predicate { + instance; + + @Override + public boolean apply(Card input, Game game) { + return input + .getManaValue() + <= game + .getState() + .getWatcher(PlayerGainedLifeWatcher.class) + .getLifeGained(input.getOwnerId()); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/r/RatchetRescueRacer.java b/Mage.Sets/src/mage/cards/r/RatchetRescueRacer.java new file mode 100644 index 00000000000..ad93ed8ed3a --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RatchetRescueRacer.java @@ -0,0 +1,61 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.abilities.common.DiesCreatureTriggeredAbility; +import mage.abilities.effects.common.TransformSourceEffect; +import mage.abilities.keyword.LifelinkAbility; +import mage.abilities.keyword.LivingMetalAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledArtifactPermanent; +import mage.filter.predicate.permanent.TokenPredicate; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RatchetRescueRacer extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledArtifactPermanent(); + + static { + filter.add(TokenPredicate.FALSE); + } + + public RatchetRescueRacer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, ""); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.VEHICLE); + this.power = new MageInt(1); + this.toughness = new MageInt(4); + this.color.setWhite(true); + this.nightCard = true; + + // Living metal + this.addAbility(new LivingMetalAbility()); + + // Lifelink + this.addAbility(LifelinkAbility.getInstance()); + + // Whenever one or more nontoken artifacts you control are put into a graveyard from the battlefield, convert Ratchet. This ability triggers only once each turn. + this.addAbility(new DiesCreatureTriggeredAbility( + new TransformSourceEffect().setText("convert {this}"), false, filter + ).setTriggerPhrase("Whenever one or more nontoken artifacts you control " + + "are put into a graveyard from the battlefield, ").setTriggersOnce(true)); + } + + private RatchetRescueRacer(final RatchetRescueRacer card) { + super(card); + } + + @Override + public RatchetRescueRacer copy() { + return new RatchetRescueRacer(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Transformers.java b/Mage.Sets/src/mage/sets/Transformers.java index 7780e0a0622..d94a3227b3c 100644 --- a/Mage.Sets/src/mage/sets/Transformers.java +++ b/Mage.Sets/src/mage/sets/Transformers.java @@ -25,6 +25,8 @@ public final class Transformers extends ExpansionSet { cards.add(new SetCardInfo("Goldbug, Scrappy Scout", 11, Rarity.MYTHIC, mage.cards.g.GoldbugScrappyScout.class)); cards.add(new SetCardInfo("Jetfire, Air Guardian", 3, Rarity.MYTHIC, mage.cards.j.JetfireAirGuardian.class)); cards.add(new SetCardInfo("Jetfire, Ingenious Scientist", 3, Rarity.MYTHIC, mage.cards.j.JetfireIngeniousScientist.class)); + cards.add(new SetCardInfo("Ratchet, Field Medic", 2, Rarity.MYTHIC, mage.cards.r.RatchetFieldMedic.class)); + cards.add(new SetCardInfo("Ratchet, Rescue Racer", 2, Rarity.MYTHIC, mage.cards.r.RatchetRescueRacer.class)); cards.add(new SetCardInfo("Ultra Magnus, Armored Carrier", 15, Rarity.MYTHIC, mage.cards.u.UltraMagnusArmoredCarrier.class)); cards.add(new SetCardInfo("Ultra Magnus, Tactician", 15, Rarity.MYTHIC, mage.cards.u.UltraMagnusTactician.class)); }