From 7d015c9ec5f4d687c98187e998b16f1a527e97fd Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 1 Jun 2023 08:41:28 -0400 Subject: [PATCH] [LTR] Implement Frodo, Determined Hero --- .../src/mage/cards/f/FrodoDeterminedHero.java | 90 +++++++++++++++++++ .../mage/cards/k/KazuulsTollCollector.java | 36 ++++---- .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + 3 files changed, 106 insertions(+), 21 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/f/FrodoDeterminedHero.java diff --git a/Mage.Sets/src/mage/cards/f/FrodoDeterminedHero.java b/Mage.Sets/src/mage/cards/f/FrodoDeterminedHero.java new file mode 100644 index 0000000000..65e834023d --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FrodoDeterminedHero.java @@ -0,0 +1,90 @@ +package mage.cards.f; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.MyTurnCondition; +import mage.abilities.decorator.ConditionalPreventionEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PreventAllDamageToSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FrodoDeterminedHero extends CardImpl { + + private static final FilterPermanent filter + = new FilterControlledPermanent("Equipment you control with mana value 2 or 3"); + + static { + filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4)); + filter.add(new ManaValuePredicate(ComparisonType.MORE_THAN, 1)); + } + + public FrodoDeterminedHero(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HALFLING); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever Frodo, Determined Hero enters the battlefield or attacks, you may attach target Equipment you control with mana value 2 or 3 to Frodo. + Ability ability = new EntersBattlefieldOrAttacksSourceTriggeredAbility(new FrodoDeterminedHeroEffect(), true); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + + // As long as it's your turn, prevent all damage that would be dealt to Frodo. + this.addAbility(new SimpleStaticAbility(new ConditionalPreventionEffect( + new PreventAllDamageToSourceEffect(Duration.WhileOnBattlefield), MyTurnCondition.instance, + "as long as it's your turn, prevent all damage that would be dealt to {this}" + ))); + } + + private FrodoDeterminedHero(final FrodoDeterminedHero card) { + super(card); + } + + @Override + public FrodoDeterminedHero copy() { + return new FrodoDeterminedHero(this); + } +} + +class FrodoDeterminedHeroEffect extends OneShotEffect { + + FrodoDeterminedHeroEffect() { + super(Outcome.Benefit); + staticText = "attach target Equipment you control with mana value 2 or 3 to {this}"; + } + + private FrodoDeterminedHeroEffect(final FrodoDeterminedHeroEffect effect) { + super(effect); + } + + @Override + public FrodoDeterminedHeroEffect copy() { + return new FrodoDeterminedHeroEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent equipment = game.getPermanent(getTargetPointer().getFirst(game, source)); + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + return permanent != null && equipment != null + && permanent.addAttachment(equipment.getId(), source, game); + } +} diff --git a/Mage.Sets/src/mage/cards/k/KazuulsTollCollector.java b/Mage.Sets/src/mage/cards/k/KazuulsTollCollector.java index 292646f1cb..6ebab38932 100644 --- a/Mage.Sets/src/mage/cards/k/KazuulsTollCollector.java +++ b/Mage.Sets/src/mage/cards/k/KazuulsTollCollector.java @@ -1,45 +1,41 @@ - package mage.cards.k; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.ActivateAsSorceryActivatedAbility; -import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledPermanent; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.target.common.TargetControlledPermanent; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author fireshoes */ public final class KazuulsTollCollector extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledPermanent("Equipment you control"); - - static { - filter.add(SubType.EQUIPMENT.getPredicate()); - } + private static final FilterPermanent filter + = new FilterControlledPermanent(SubType.EQUIPMENT, "Equipment you control"); public KazuulsTollCollector(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); this.subtype.add(SubType.OGRE); this.subtype.add(SubType.WARRIOR); this.power = new MageInt(3); this.toughness = new MageInt(2); // {0}: Attach target Equipment you control to Kazuul's Toll Collector. Activate this ability only any time you could cast a sorcery. - Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new KazuulsTollCollectorEffect(), new ManaCostsImpl<>("{0}")); - ability.addTarget(new TargetControlledPermanent(filter)); + Ability ability = new ActivateAsSorceryActivatedAbility(new KazuulsTollCollectorEffect(), new GenericManaCost(0)); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } @@ -57,7 +53,7 @@ class KazuulsTollCollectorEffect extends OneShotEffect { public KazuulsTollCollectorEffect() { super(Outcome.BoostCreature); - staticText = "Attach target Equipment you control to {this}"; + staticText = "attach target Equipment you control to {this}"; } public KazuulsTollCollectorEffect(final KazuulsTollCollectorEffect effect) { @@ -71,11 +67,9 @@ class KazuulsTollCollectorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent equipment = game.getPermanent(source.getFirstTarget()); - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null && equipment != null) { - return permanent.addAttachment(equipment.getId(), source, game); - } - return false; + Permanent equipment = game.getPermanent(getTargetPointer().getFirst(game, source)); + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + return permanent != null && equipment != null + && permanent.addAttachment(equipment.getId(), source, game); } } diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index 90ab8bbd19..c32f910641 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -33,6 +33,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Foray of Orcs", 128, Rarity.UNCOMMON, mage.cards.f.ForayOfOrcs.class)); cards.add(new SetCardInfo("Forest", 270, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Frodo Baggins", 205, Rarity.UNCOMMON, mage.cards.f.FrodoBaggins.class)); + cards.add(new SetCardInfo("Frodo, Determined Hero", 388, Rarity.RARE, mage.cards.f.FrodoDeterminedHero.class)); cards.add(new SetCardInfo("Frodo, Sauron's Bane", 18, Rarity.RARE, mage.cards.f.FrodoSauronsBane.class)); cards.add(new SetCardInfo("Galadhrim Bow", 167, Rarity.COMMON, mage.cards.g.GaladhrimBow.class)); cards.add(new SetCardInfo("Galadriel, Gift-Giver", 296, Rarity.RARE, mage.cards.g.GaladrielGiftGiver.class));