From be72a5bba6f925c528f844967479ebc7d78a6fc1 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:59:06 +0200 Subject: [PATCH] implement [MH3] Aether Revolt --- Mage.Sets/src/mage/cards/a/AetherRevolt.java | 136 ++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons3.java | 1 + .../condition/common/RevoltCondition.java | 10 ++ 3 files changed, 147 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AetherRevolt.java diff --git a/Mage.Sets/src/mage/cards/a/AetherRevolt.java b/Mage.Sets/src/mage/cards/a/AetherRevolt.java new file mode 100644 index 00000000000..44ac399f2d1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AetherRevolt.java @@ -0,0 +1,136 @@ +package mage.cards.a; + +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.RevoltCondition; +import mage.abilities.decorator.ConditionalReplacementEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.DamageEvent; +import mage.game.events.GameEvent; +import mage.players.Player; +import mage.target.common.TargetAnyTarget; +import mage.util.CardUtil; +import mage.watchers.common.RevoltWatcher; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class AetherRevolt extends CardImpl { + + public AetherRevolt(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}"); + + // Revolt -- As long as a permanent you controlled left the battlefield this turn, if a source you control would deal noncombat damage to an opponent or a permanent an opponent controls, it deals that much damage plus 2 instead. + this.addAbility(new SimpleStaticAbility(new ConditionalReplacementEffect( + new AetherRevoltEffect(), RevoltCondition.instance + ).setText("As long as a permanent you controlled left the battlefield this turn, " + + "if a source you control would deal noncombat damage to an opponent or a permanent an opponent controls, " + + "it deals that much damage plus 2 instead") + ).setAbilityWord(AbilityWord.REVOLT).addHint(RevoltCondition.getHint()), new RevoltWatcher()); + + // Whenever you get one or more {E}, Aether Revolt deals that much damage to any target. + this.addAbility(new AetherRevoltTriggeredAbility()); + } + + private AetherRevolt(final AetherRevolt card) { + super(card); + } + + @Override + public AetherRevolt copy() { + return new AetherRevolt(this); + } +} + +class AetherRevoltEffect extends ReplacementEffectImpl { + + AetherRevoltEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "if a source you control would deal noncombat damage to an opponent or a permanent an opponent controls, " + + "it deals that much damage plus 2 instead"; + } + + private AetherRevoltEffect(final AetherRevoltEffect effect) { + super(effect); + } + + @Override + public AetherRevoltEffect copy() { + return new AetherRevoltEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + return source.isControlledBy(game.getControllerId(event.getSourceId())) + && !((DamageEvent) event).isCombatDamage() + && (player.hasOpponent(event.getTargetId(), game) + || player.hasOpponent(game.getControllerId(event.getTargetId()), game)); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmount(CardUtil.overflowInc(event.getAmount(), 2)); + return false; + } +} + +class AetherRevoltTriggeredAbility extends TriggeredAbilityImpl { + + AetherRevoltTriggeredAbility() { + super(Zone.BATTLEFIELD, null, false); + this.addTarget(new TargetAnyTarget()); + } + + private AetherRevoltTriggeredAbility(final AetherRevoltTriggeredAbility ability) { + super(ability); + } + + @Override + public AetherRevoltTriggeredAbility copy() { + return new AetherRevoltTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.COUNTERS_ADDED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!event.getData().equals(CounterType.ENERGY.getName()) + || !getControllerId().equals(event.getTargetId())) { + return false; + } + int amount = event.getAmount(); + if (amount <= 0) { + return false; + } + this.getEffects().clear(); + this.getEffects().add(new DamageTargetEffect(amount)); + return true; + } + + @Override + public String getRule() { + return "Whenever you get one or more {E}, {this} deals that much damage to any target."; + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index 07fdb97ce7a..7f6cc7c2a85 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -23,6 +23,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Accursed Marauder", 80, Rarity.COMMON, mage.cards.a.AccursedMarauder.class)); cards.add(new SetCardInfo("Aerie Auxiliary", 18, Rarity.COMMON, mage.cards.a.AerieAuxiliary.class)); + cards.add(new SetCardInfo("Aether Revolt", 113, Rarity.RARE, mage.cards.a.AetherRevolt.class)); cards.add(new SetCardInfo("Aether Spike", 50, Rarity.COMMON, mage.cards.a.AetherSpike.class)); cards.add(new SetCardInfo("Ajani Fells the Godsire", 19, Rarity.UNCOMMON, mage.cards.a.AjaniFellsTheGodsire.class)); cards.add(new SetCardInfo("Ajani, Nacatl Avenger", 237, Rarity.MYTHIC, mage.cards.a.AjaniNacatlAvenger.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java b/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java index ebb1bdd6a00..530f657ca38 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java @@ -3,16 +3,26 @@ package mage.abilities.condition.common; import mage.abilities.Ability; import mage.abilities.condition.Condition; +import mage.abilities.hint.ConditionHint; +import mage.abilities.hint.Hint; import mage.game.Game; import mage.watchers.common.RevoltWatcher; /** + * Needs RevoltWatcher to work. + * * @author emerald000 */ public enum RevoltCondition implements Condition { instance; + private static final Hint hint = new ConditionHint(instance); + + public static Hint getHint() { + return hint; + } + @Override public boolean apply(Game game, Ability source) { RevoltWatcher watcher = game.getState().getWatcher(RevoltWatcher.class);