* Clash ability - fixed that some clash cards can broke the server (#10097)

Co-authored-by: Ethan Ward <ethanandrewward@gmail.com>
This commit is contained in:
bobwoco 2023-03-05 01:29:46 -06:00 committed by GitHub
parent 1b54659c7d
commit 6102ccee53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 62 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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