mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10: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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,4 +86,32 @@ public class SuspendTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
|
||||
}
|
||||
/**
|
||||
* Tests that a spell countered with delay goes to exile with 3 time counters
|
||||
* and can be cast after the 3 counters are removed
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDelay() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
|
||||
|
||||
addCard(Zone.HAND, playerA, "Silvercoat Lion",1);
|
||||
|
||||
// Instant {1}{U}
|
||||
// Counter target spell. If the spell is countered this way, exile it with three time counters on it instead of putting it into its owner's graveyard. If it doesn't have suspend, it gains suspend. (At the beginning of its owner's upkeep, remove a counter from that card. When the last is removed, the player plays it without paying its mana cost. If it's a creature, it has haste.)
|
||||
addCard(Zone.HAND, playerB, "Delay",1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Delay", "Silvercoat Lion");
|
||||
setChoice(playerA, "Silvercoat Lion");
|
||||
|
||||
setStopAt(7, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerB, "Delay", 1);
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class GainSuspendEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
MageObjectReference mor;
|
||||
|
||||
public GainSuspendEffect(MageObjectReference mor) {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.mor = mor;
|
||||
staticText = "{this} gains suspend";
|
||||
}
|
||||
|
||||
public GainSuspendEffect(final GainSuspendEffect effect) {
|
||||
super(effect);
|
||||
this.mor = effect.mor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainSuspendEffect copy() {
|
||||
return new GainSuspendEffect(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
Reference in a new issue