mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
* Delay - Fixed that suspend of the xiled spell did not work.
This commit is contained in:
parent
f11a85f1a0
commit
57d8cd6ff4
5 changed files with 120 additions and 97 deletions
|
|
@ -28,11 +28,12 @@
|
|||
package mage.sets.futuresight;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CounterTargetWithReplacementEffect;
|
||||
import mage.abilities.effects.common.continuous.GainSuspendEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -98,32 +99,15 @@ class DelayEffect extends OneShotEffect {
|
|||
effect.setTargetPointer(targetPointer);
|
||||
Card card = game.getCard(spell.getSourceId());
|
||||
if (card != null && effect.apply(game, source) && Zone.EXILED.equals(game.getState().getZone(card.getId()))) {
|
||||
boolean hasSuspend = false;
|
||||
for (Ability ability :card.getAbilities()) {
|
||||
if (ability instanceof SuspendAbility) {
|
||||
hasSuspend = true;
|
||||
break;
|
||||
boolean hasSuspend = card.getAbilities().containsClass(SuspendAbility.class);
|
||||
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
|
||||
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.HAND, true)) {
|
||||
card.addCounters(CounterType.TIME.createInstance(3), game);
|
||||
if (!hasSuspend) {
|
||||
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
|
||||
}
|
||||
}
|
||||
card.addCounters(CounterType.TIME.createInstance(3), game);
|
||||
if (!hasSuspend) {
|
||||
// add suspend ability
|
||||
// TODO: Find a better solution for giving suspend to a card.
|
||||
// If the exiled card leaves exile by another way, the abilites won't be removed from the card
|
||||
Abilities oldAbilities = card.getAbilities().copy();
|
||||
SuspendAbility suspendAbility = new SuspendAbility(3, null, card);
|
||||
game.getState().addOtherAbility(card, suspendAbility);
|
||||
|
||||
for (Ability ability :card.getAbilities()) {
|
||||
if (!oldAbilities.contains(ability)) {
|
||||
ability.setControllerId(source.getControllerId());
|
||||
game.getState().addAbility(ability, card.getId(), card);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
game.informPlayers(new StringBuilder(controller.getName()).append(" suspends (").append(3).append(") ").append(card.getName()).toString());
|
||||
|
||||
game.informPlayers(controller.getName() + " suspends 3 - " + card.getName());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,24 +29,21 @@ package mage.sets.modernmasters;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.InvertCondition;
|
||||
import mage.abilities.condition.common.CastFromHandCondition;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.SourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainSuspendEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
|
|
@ -113,38 +110,10 @@ class EpochrasiteEffect extends OneShotEffect {
|
|||
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
|
||||
controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
card.addCounters(CounterType.TIME.createInstance(3), game);
|
||||
game.addEffect(new GainSuspendEffect(), source);
|
||||
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class GainSuspendEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
public GainSuspendEffect() {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
staticText = "{this} gains suspend";
|
||||
}
|
||||
|
||||
public GainSuspendEffect(final GainSuspendEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainSuspendEffect copy() {
|
||||
return new GainSuspendEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
|
||||
SuspendAbility.addSuspendTemporaryToCard(card, source, game);
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,18 +37,14 @@ import mage.abilities.common.SimpleActivatedAbility;
|
|||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.ExileFromHandCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.SourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainSuspendEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterNonlandCard;
|
||||
|
|
@ -127,7 +123,7 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
|
|||
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.HAND, true)) {
|
||||
card.addCounters(CounterType.TIME.createInstance(4), game);
|
||||
if (!hasSuspend) {
|
||||
game.addEffect(new JhoiraGainSuspendEffect(new MageObjectReference(card, game)), source);
|
||||
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
|
||||
}
|
||||
game.informPlayers(controller.getName() + " suspends 4 - " + card.getName());
|
||||
return true;
|
||||
|
|
@ -137,34 +133,3 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
|
||||
class JhoiraGainSuspendEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
MageObjectReference mor;
|
||||
|
||||
public JhoiraGainSuspendEffect(MageObjectReference mor) {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.mor = mor;
|
||||
staticText = "{this} gains suspend";
|
||||
}
|
||||
|
||||
public JhoiraGainSuspendEffect(final JhoiraGainSuspendEffect effect) {
|
||||
super(effect);
|
||||
this.mor = effect.mor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JhoiraGainSuspendEffect copy() {
|
||||
return new JhoiraGainSuspendEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(mor.getSourceId());
|
||||
if (card != null && mor.refersTo(card, game) && game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
|
||||
SuspendAbility.addSuspendTemporaryToCard(card, source, game);
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue