From 6102ccee537ca2d634ffcbf21469676ba13b39ed Mon Sep 17 00:00:00 2001 From: bobwoco Date: Sun, 5 Mar 2023 01:29:46 -0600 Subject: [PATCH] * Clash ability - fixed that some clash cards can broke the server (#10097) Co-authored-by: Ethan Ward --- .../src/mage/cards/r/RecrossThePaths.java | 6 ++- Mage.Sets/src/mage/cards/r/RedeemTheLost.java | 7 +-- .../src/mage/cards/r/ReleaseTheAnts.java | 6 ++- .../src/mage/cards/r/ResearchTheDeep.java | 6 ++- .../src/mage/cards/r/ReviveTheFallen.java | 6 ++- Mage.Sets/src/mage/cards/t/TitansRevenge.java | 5 +- .../ClashWinReturnToHandSpellEffect.java | 49 ------------------- 7 files changed, 23 insertions(+), 62 deletions(-) delete mode 100644 Mage/src/main/java/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java diff --git a/Mage.Sets/src/mage/cards/r/RecrossThePaths.java b/Mage.Sets/src/mage/cards/r/RecrossThePaths.java index 9eb9d4c10d..7e611c4344 100644 --- a/Mage.Sets/src/mage/cards/r/RecrossThePaths.java +++ b/Mage.Sets/src/mage/cards/r/RecrossThePaths.java @@ -2,7 +2,9 @@ package mage.cards.r; import java.util.UUID; -import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; + +import mage.abilities.effects.common.DoIfClashWonEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -23,7 +25,7 @@ public final class RecrossThePaths extends CardImpl { this.getSpellAbility().addEffect(new RevealCardsFromLibraryUntilEffect(new FilterLandCard(), Zone.BATTLEFIELD, Zone.LIBRARY, false, true)); // Clash with an opponent. If you win, return Recross the Paths to its owner's hand. - this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new DoIfClashWonEffect(ReturnToHandSpellEffect.getInstance())); } private RecrossThePaths(final RecrossThePaths card) { diff --git a/Mage.Sets/src/mage/cards/r/RedeemTheLost.java b/Mage.Sets/src/mage/cards/r/RedeemTheLost.java index 16b5a15516..988ea52692 100644 --- a/Mage.Sets/src/mage/cards/r/RedeemTheLost.java +++ b/Mage.Sets/src/mage/cards/r/RedeemTheLost.java @@ -2,14 +2,15 @@ package mage.cards.r; import java.util.UUID; -import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; + +import mage.abilities.effects.common.DoIfClashWonEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.target.common.TargetControlledCreaturePermanent; -import mage.target.common.TargetCreaturePermanent; /** * @@ -24,7 +25,7 @@ public final class RedeemTheLost extends CardImpl { this.getSpellAbility().addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn)); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); // Clash with an opponent. If you win, return Redeem the Lost to its owner's hand. - this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new DoIfClashWonEffect(ReturnToHandSpellEffect.getInstance())); } private RedeemTheLost(final RedeemTheLost card) { diff --git a/Mage.Sets/src/mage/cards/r/ReleaseTheAnts.java b/Mage.Sets/src/mage/cards/r/ReleaseTheAnts.java index d39ca41380..e32b4fb87a 100644 --- a/Mage.Sets/src/mage/cards/r/ReleaseTheAnts.java +++ b/Mage.Sets/src/mage/cards/r/ReleaseTheAnts.java @@ -2,8 +2,10 @@ package mage.cards.r; import java.util.UUID; -import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; + import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DoIfClashWonEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -22,7 +24,7 @@ public final class ReleaseTheAnts extends CardImpl { // Release the Ants deals 1 damage to any target. Clash with an opponent. If you win, return Release the Ants to its owner's hand. this.getSpellAbility().addEffect(new DamageTargetEffect(1)); this.getSpellAbility().addTarget(new TargetAnyTarget()); - this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new DoIfClashWonEffect(ReturnToHandSpellEffect.getInstance())); } private ReleaseTheAnts(final ReleaseTheAnts card) { diff --git a/Mage.Sets/src/mage/cards/r/ResearchTheDeep.java b/Mage.Sets/src/mage/cards/r/ResearchTheDeep.java index fd47349573..1d5fed5638 100644 --- a/Mage.Sets/src/mage/cards/r/ResearchTheDeep.java +++ b/Mage.Sets/src/mage/cards/r/ResearchTheDeep.java @@ -2,8 +2,10 @@ package mage.cards.r; import java.util.UUID; -import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; + +import mage.abilities.effects.common.DoIfClashWonEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -20,7 +22,7 @@ public final class ResearchTheDeep extends CardImpl { // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); // Clash with an opponent. If you win, return Research the Deep to its owner's hand. - this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new DoIfClashWonEffect(ReturnToHandSpellEffect.getInstance())); } private ResearchTheDeep(final ResearchTheDeep card) { diff --git a/Mage.Sets/src/mage/cards/r/ReviveTheFallen.java b/Mage.Sets/src/mage/cards/r/ReviveTheFallen.java index 3e90df0071..96524669ff 100644 --- a/Mage.Sets/src/mage/cards/r/ReviveTheFallen.java +++ b/Mage.Sets/src/mage/cards/r/ReviveTheFallen.java @@ -2,7 +2,9 @@ package mage.cards.r; import java.util.UUID; -import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; + +import mage.abilities.effects.common.DoIfClashWonEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -23,7 +25,7 @@ public final class ReviveTheFallen extends CardImpl { this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); this.getSpellAbility().addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card from a graveyard"))); // Clash with an opponent. If you win, return Revive the Fallen to its owner's hand. - this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new DoIfClashWonEffect(ReturnToHandSpellEffect.getInstance())); } private ReviveTheFallen(final ReviveTheFallen card) { diff --git a/Mage.Sets/src/mage/cards/t/TitansRevenge.java b/Mage.Sets/src/mage/cards/t/TitansRevenge.java index 5875610dde..4002f0a911 100644 --- a/Mage.Sets/src/mage/cards/t/TitansRevenge.java +++ b/Mage.Sets/src/mage/cards/t/TitansRevenge.java @@ -3,8 +3,9 @@ package mage.cards.t; import java.util.UUID; import mage.abilities.dynamicvalue.common.ManacostVariableValue; -import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DoIfClashWonEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -23,7 +24,7 @@ public final class TitansRevenge extends CardImpl { // Titan's Revenge deals X damage to any target. Clash with an opponent. If you win, return Titan's Revenge to its owner's hand. this.getSpellAbility().addEffect(new DamageTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addTarget(new TargetAnyTarget()); - this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new DoIfClashWonEffect(ReturnToHandSpellEffect.getInstance())); } private TitansRevenge(final TitansRevenge card) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java deleted file mode 100644 index 71e4556859..0000000000 --- a/Mage/src/main/java/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java +++ /dev/null @@ -1,49 +0,0 @@ - -package mage.abilities.effects.common; - -import mage.abilities.Ability; -import mage.abilities.MageSingleton; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; - -/** - * - * @author LevelX2 - */ -public class ClashWinReturnToHandSpellEffect extends OneShotEffect implements MageSingleton { - - private static final ClashWinReturnToHandSpellEffect instance = new ClashWinReturnToHandSpellEffect(); - - public static ClashWinReturnToHandSpellEffect getInstance() { - return instance; - } - - private ClashWinReturnToHandSpellEffect() { - super(Outcome.ReturnToHand); - staticText = "Clash with an opponent. If you win, return {this} to its owner's hand"; - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - if (ClashEffect.getInstance().apply(game, source)) { - Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); - if (spellCard != null) { - controller.moveCards(spellCard, Zone.HAND, source, game); - } - } - return true; - } - return false; - } - - @Override - public ClashWinReturnToHandSpellEffect copy() { - return instance; - } -}