Rework cards which exile cards and add suspend to them (Ready for review) (#13600)

* rework effects which exile cards and give suspend

* fix test failure

* remove extra zone change

* [WHO] Implement The Wedding of River Song

* [WHO] Implement The Eleventh Doctor

* [WHO] Implement The Parting of the Ways
This commit is contained in:
Evan Kranzler 2025-05-06 17:49:43 -04:00 committed by GitHub
parent 61d95a1785
commit 264eb58644
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 406 additions and 323 deletions

View file

@ -1,88 +0,0 @@
package mage.abilities.costs.common;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.common.continuous.GainSuspendEffect;
import mage.abilities.keyword.SuspendAbility;
import mage.cards.Card;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.MageObjectReference;
import mage.players.Player;
/**
* @author padfoot
*/
public class ExileSourceWithTimeCountersCost extends CostImpl {
private final int counters;
private final boolean checksSuspend;
private final boolean givesSuspend;
private final Zone fromZone;
public ExileSourceWithTimeCountersCost(int counters) {
this (counters, true, false, null);
}
public ExileSourceWithTimeCountersCost(int counters, boolean givesSuspend, boolean checksSuspend, Zone fromZone) {
this.counters = counters;
this.givesSuspend = givesSuspend;
this.checksSuspend = checksSuspend;
this.fromZone = fromZone;
this.text = "exile {this} " +
((fromZone != null) ? " from your " + fromZone.toString().toLowerCase(Locale.ENGLISH) : "") +
" and put " + counters + " time counters on it" +
(givesSuspend ? ". It gains suspend" : "") +
(checksSuspend ? ". If it doesn't have suspend, it gains suspend" : "");
}
private ExileSourceWithTimeCountersCost(final ExileSourceWithTimeCountersCost cost) {
super(cost);
this.counters = cost.counters;
this.givesSuspend = cost.givesSuspend;
this.checksSuspend = cost.checksSuspend;
this.fromZone = cost.fromZone;
}
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller == null) {
return paid;
}
Card card = game.getCard(source.getSourceId());
boolean hasSuspend = card.getAbilities(game).containsClass(SuspendAbility.class);
if (card != null && (fromZone == null || fromZone == game.getState().getZone(source.getSourceId()))) {
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (controller.moveCardsToExile(card, source, game, true, exileId, "Suspended cards of " + controller.getName())) {
card.addCounters(CounterType.TIME.createInstance(counters), controller.getId(), source, game);
game.informPlayers(controller.getLogName() + " exiles " + card.getLogName() + ((fromZone != null) ? " from their " + fromZone.toString().toLowerCase(Locale.ENGLISH) : "") + " with " + counters + " time counters on it.");
if (givesSuspend || (checksSuspend && !hasSuspend)) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
}
// 117.11. The actions performed when paying a cost may be modified by effects.
// Even if they are, meaning the actions that are performed don't match the actions
// that are called for, the cost has still been paid.
// so return state here is not important because the user indended to exile the target anyway
paid = true;
}
return paid;
}
@Override
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
return (game.getCard(source.getSourceId()) != null && (fromZone == null || fromZone == game.getState().getZone(source.getSourceId())));
}
@Override
public ExileSourceWithTimeCountersCost copy() {
return new ExileSourceWithTimeCountersCost(this);
}
}

View file

@ -23,7 +23,7 @@ public class ExileSpellWithTimeCountersEffect extends OneShotEffect {
private final boolean gainsSuspend;
public ExileSpellWithTimeCountersEffect(int counters) {
this (counters, false);
this(counters, false);
}
public ExileSpellWithTimeCountersEffect(int counters, boolean gainsSuspend) {
@ -33,6 +33,7 @@ public class ExileSpellWithTimeCountersEffect extends OneShotEffect {
this.staticText = "exile {this} with " + CardUtil.numberToText(this.counters) + " time counters on it"
+ (gainsSuspend ? ". It gains suspend" : "");
}
private ExileSpellWithTimeCountersEffect(final ExileSpellWithTimeCountersEffect effect) {
super(effect);
this.counters = effect.counters;

View file

@ -1,10 +1,10 @@
package mage.abilities.keyword;
import mage.MageIdentifier;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.SpecialAction;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.SuspendedCondition;
import mage.abilities.costs.VariableCostType;
import mage.abilities.costs.mana.ManaCost;
@ -14,7 +14,9 @@ import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainSuspendEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.cards.ModalDoubleFacedCard;
@ -230,6 +232,34 @@ public class SuspendAbility extends SpecialAction {
return super.canActivate(playerId, game);
}
public static boolean addTimeCountersAndSuspend(Card card, int amount, Ability source, Game game) {
if (card == null || card.isCopy()) {
return false;
}
if (!Zone.EXILED.match(game.getState().getZone(card.getId()))) {
return false;
}
Player owner = game.getPlayer(card.getOwnerId());
if (owner == null) {
return false;
}
game.getExile().moveToAnotherZone(
card.getMainCard(), game,
game.getExile().createZone(
SuspendAbility.getSuspendExileId(owner.getId(), game),
"Suspended cards of " + owner.getName()
)
);
if (amount > 0) {
card.addCounters(CounterType.TIME.createInstance(amount), owner.getId(), source, game);
}
if (!card.getAbilities(game).containsClass(SuspendAbility.class)) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(owner.getLogName() + " suspends " + amount + " - " + card.getName());
return true;
}
@Override
public String getRule() {
return ruleText;