From b15a836a8a3c7fa0c173e579b2b9ff2619188ee8 Mon Sep 17 00:00:00 2001 From: PurpleCrowbar <26198472+PurpleCrowbar@users.noreply.github.com> Date: Thu, 9 Feb 2023 03:19:58 +0000 Subject: [PATCH] [ONC] Implement Roar of Resistance (#9936) --- .../src/mage/cards/r/RoarOfResistance.java | 109 ++++++++++++++++++ .../sets/PhyrexiaAllWillBeOneCommander.java | 2 + 2 files changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RoarOfResistance.java diff --git a/Mage.Sets/src/mage/cards/r/RoarOfResistance.java b/Mage.Sets/src/mage/cards/r/RoarOfResistance.java new file mode 100644 index 0000000000..02c9c44051 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RoarOfResistance.java @@ -0,0 +1,109 @@ +package mage.cards.r; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.continuous.BoostAllEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; + +import java.util.Set; +import java.util.UUID; + +/** + * @author PurpleCrowbar + */ +public final class RoarOfResistance extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures attacking your opponents"); + + static { + filter.add(RoarOfResistancePredicate.instance); + } + + public RoarOfResistance(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}"); + + // Creature tokens you control have haste. + this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( + HasteAbility.getInstance(), Duration.WhileOnBattlefield, StaticFilters.FILTER_CREATURE_TOKENS + ))); + + // Whenever one or more creatures attack, you may pay {1}{R}. If you do, creatures attacking + // your opponents and/or planeswalkers they control get +2/+0 until end of turn. + this.addAbility(new RoarOfResistanceTriggeredAbility(Zone.BATTLEFIELD, new DoIfCostPaid( + new BoostAllEffect(2, 0, Duration.EndOfTurn, filter, false), new ManaCostsImpl<>("{1}{R}") + ))); + } + + private RoarOfResistance(final RoarOfResistance card) { + super(card); + } + + @Override + public RoarOfResistance copy() { + return new RoarOfResistance(this); + } +} + +enum RoarOfResistancePredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + UUID defenderId = game.getCombat().getDefenderId(input.getObject().getId()); + Set opponents = game.getOpponents(input.getSource().getControllerId()); + Permanent attackedPlaneswalker = game.getPermanent(defenderId); + if (attackedPlaneswalker != null + && attackedPlaneswalker.isPlaneswalker(game) + && opponents.contains(attackedPlaneswalker.getControllerId())) { + return true; + } else return opponents.contains(defenderId); + } +} + +class RoarOfResistanceTriggeredAbility extends TriggeredAbilityImpl { + + public RoarOfResistanceTriggeredAbility(Zone zone, Effect effect) { + super(zone, effect, false); + } + + public RoarOfResistanceTriggeredAbility(final RoarOfResistanceTriggeredAbility ability) { + super(ability); + } + + @Override + public RoarOfResistanceTriggeredAbility copy() { + return new RoarOfResistanceTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return !game.getCombat().getAttackers().isEmpty(); + } + + @Override + public String getRule() { + return "Whenever one or more creatures attack, you may pay {1}{R}. If you do, creatures attacking your opponents " + + "and/or planeswalkers they control get +2/+0 until end of turn."; + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOneCommander.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOneCommander.java index 9a54a211fa..f31d560cfc 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOneCommander.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOneCommander.java @@ -113,6 +113,8 @@ public final class PhyrexiaAllWillBeOneCommander extends ExpansionSet { cards.add(new SetCardInfo("Prava of the Steel Legion", 87, Rarity.UNCOMMON, mage.cards.p.PravaOfTheSteelLegion.class)); cards.add(new SetCardInfo("Putrefy", 123, Rarity.UNCOMMON, mage.cards.p.Putrefy.class)); cards.add(new SetCardInfo("Rip Apart", 124, Rarity.UNCOMMON, mage.cards.r.RipApart.class)); + cards.add(new SetCardInfo("Roar of Resistance", 15, Rarity.RARE, mage.cards.r.RoarOfResistance.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Roar of Resistance", 53, Rarity.RARE, mage.cards.r.RoarOfResistance.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Sandsteppe Citadel", 162, Rarity.UNCOMMON, mage.cards.s.SandsteppeCitadel.class)); cards.add(new SetCardInfo("Scavenging Ooze", 112, Rarity.RARE, mage.cards.s.ScavengingOoze.class)); cards.add(new SetCardInfo("Secluded Steppe", 163, Rarity.UNCOMMON, mage.cards.s.SecludedSteppe.class));