From b79da551f16292e902f70f5a41f5c1dbb5fc66ad Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Sat, 24 Jun 2023 02:14:31 +0200 Subject: [PATCH] [LTR] Implement Friendly Rivalry (#10505) --- .../src/mage/cards/f/FriendlyRivalry.java | 110 ++++++++++++++++++ .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + 2 files changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FriendlyRivalry.java diff --git a/Mage.Sets/src/mage/cards/f/FriendlyRivalry.java b/Mage.Sets/src/mage/cards/f/FriendlyRivalry.java new file mode 100644 index 0000000000..a04058f3c4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FriendlyRivalry.java @@ -0,0 +1,110 @@ +package mage.cards.f; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.other.AnotherTargetPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.Target; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author Susucr + */ +public final class FriendlyRivalry extends CardImpl { + + private static final FilterControlledCreaturePermanent filter2 = new FilterControlledCreaturePermanent("other target legendary creature you control"); + + static { + filter2.add(new AnotherTargetPredicate(2)); + filter2.add(SuperType.LEGENDARY.getPredicate()); + } + + public FriendlyRivalry(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{R}{G}"); + + + // Target creature you control and up to one other target legendary creature you control + // each deal damage equal to their power to target creature you don't control. + this.getSpellAbility().addEffect(new FriendlyRivalryEffect()); + + TargetControlledCreaturePermanent target1 = new TargetControlledCreaturePermanent(); + this.getSpellAbility().addTarget(target1.setTargetTag(1)); + + TargetControlledCreaturePermanent target2 = new TargetControlledCreaturePermanent(0, 1, filter2, false); + this.getSpellAbility().addTarget(target2.setTargetTag(2)); + + TargetCreaturePermanent target3 = new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL); + this.getSpellAbility().addTarget(target3); + } + + private FriendlyRivalry(final FriendlyRivalry card) { + super(card); + } + + @Override + public FriendlyRivalry copy() { + return new FriendlyRivalry(this); + } +} + +class FriendlyRivalryEffect extends OneShotEffect { + + FriendlyRivalryEffect() { + super(Outcome.Benefit); + staticText = "Target creature you control and up to one other target legendary " + + "creature you control each deal damage equal to their power to target creature you don't control."; + } + + private FriendlyRivalryEffect(final FriendlyRivalryEffect effect) { + super(effect); + } + + @Override + public FriendlyRivalryEffect copy() { + return new FriendlyRivalryEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int size = source.getTargets().size(); + if (size < 2) { + return false; + } + + Target damageTarget1 = source.getTargets().get(0); + Target damageTarget2 = size == 3 ? source.getTargets().get(1) : null; + + Target destTarget = source.getTargets().get(size-1); + if ((damageTarget1.getTargets().isEmpty() && (damageTarget2 == null || damageTarget2.getTargets().isEmpty())) + || destTarget.getTargets().isEmpty()) { + return false; + } + + Permanent permanentDamage1 = damageTarget1.getTargets().isEmpty() ? null + : game.getPermanent(damageTarget1.getTargets().get(0)); + Permanent permanentDamage2 = damageTarget2 == null || damageTarget2.getTargets().isEmpty() ? null + : game.getPermanent(damageTarget2.getTargets().get(0)); + Permanent permanentDest = game.getPermanent(destTarget.getTargets().get(0)); + if (permanentDest == null){ + return false; + } + + if (permanentDamage1 != null) { + permanentDest.damage(permanentDamage1.getPower().getValue(), permanentDamage1.getId(), source, game, false, true); + } + if (permanentDamage2 != null) { + permanentDest.damage(permanentDamage2.getPower().getValue(), permanentDamage2.getId(), source, game, false, true); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index 444c5235a8..e221f0e4bc 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -90,6 +90,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Fog on the Barrow-Downs", 16, Rarity.COMMON, mage.cards.f.FogOnTheBarrowDowns.class)); 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("Friendly Rivalry", 204, Rarity.UNCOMMON, mage.cards.f.FriendlyRivalry.class)); cards.add(new SetCardInfo("Frodo Baggins", 205, Rarity.UNCOMMON, mage.cards.f.FrodoBaggins.class)); cards.add(new SetCardInfo("Frodo, Determined Hero", 289, Rarity.RARE, mage.cards.f.FrodoDeterminedHero.class)); cards.add(new SetCardInfo("Frodo, Sauron's Bane", 18, Rarity.RARE, mage.cards.f.FrodoSauronsBane.class));