[ONC] Implement Roar of Resistance (#9936)

This commit is contained in:
PurpleCrowbar 2023-02-09 03:19:58 +00:00 committed by GitHub
parent 38d5ed0bf4
commit b15a836a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 111 additions and 0 deletions

View file

@ -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<Permanent> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
UUID defenderId = game.getCombat().getDefenderId(input.getObject().getId());
Set<UUID> 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.";
}
}

View file

@ -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));