mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Removed PostResolveEffect class.
This commit is contained in:
parent
1cb3012c37
commit
966e8d1698
51 changed files with 305 additions and 735 deletions
|
@ -35,7 +35,7 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
|
|
|
@ -27,15 +27,14 @@
|
|||
*/
|
||||
package mage.sets.avacynrestored;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect;
|
||||
import mage.abilities.keyword.MiracleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.discard.DiscardControllerEffect;
|
||||
import mage.abilities.effects.postresolve.ReturnToHandSpellEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import mage.MageObject;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.postresolve.ReturnToLibrarySpellEffect;
|
||||
import mage.abilities.effects.common.ReturnToLibrarySpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
|
|
|
@ -27,30 +27,32 @@
|
|||
*/
|
||||
package mage.sets.conflux;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandSpellEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public class ViewFromAbove extends CardImpl {
|
||||
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("white permanent you control");
|
||||
static {
|
||||
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
}
|
||||
|
||||
public ViewFromAbove(UUID ownerId) {
|
||||
super(ownerId, 38, "View from Above", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
|
||||
this.expansionSetCode = "CON";
|
||||
|
@ -61,7 +63,10 @@ public class ViewFromAbove extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
// If you control a white permanent, return View from Above to its owner's hand.
|
||||
this.getSpellAbility().addEffect(new ViewFromAboveEffect());
|
||||
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
|
||||
ReturnToHandSpellEffect.getInstance(),
|
||||
new PermanentsOnTheBattlefieldCondition(filter),
|
||||
"If you control a white permanent, return {this} to its owner's hand"));
|
||||
}
|
||||
|
||||
public ViewFromAbove(final ViewFromAbove card) {
|
||||
|
@ -73,31 +78,3 @@ public class ViewFromAbove extends CardImpl {
|
|||
return new ViewFromAbove(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ViewFromAboveEffect extends PostResolveEffect {
|
||||
|
||||
public ViewFromAboveEffect() {
|
||||
this.staticText = "If you control a white permanent, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public ViewFromAboveEffect(final ViewFromAboveEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewFromAboveEffect copy() {
|
||||
return new ViewFromAboveEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
FilterPermanent filter = new FilterPermanent("white permanent");
|
||||
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
|
||||
if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
} else {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.sets.dragonsoftarkir;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -35,7 +35,7 @@ import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredA
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.sets.fatereforged;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.keyword.DelveAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -28,12 +28,12 @@
|
|||
package mage.sets.fifthdawn;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.permanent.token.InsectToken;
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.turn.TurnMod;
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.sets.fifthedition;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -29,21 +29,12 @@ package mage.sets.guildpact;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.SacrificeEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
|
@ -51,7 +42,6 @@ import mage.filter.FilterPermanent;
|
|||
import mage.filter.FilterSpell;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -70,8 +60,7 @@ public class SpelltitheEnforcer extends CardImpl {
|
|||
// Whenever an opponent casts a spell, that player sacrifices a permanent unless he or she pays {1}.
|
||||
this.addAbility(new SpellCastOpponentTriggeredAbility(
|
||||
Zone.BATTLEFIELD,
|
||||
new DoUnlessTargetPaysEffect(new SacrificeEffect(new FilterPermanent(), 1, "that player"), new GenericManaCost(1),
|
||||
"Pay {1}? (otherwise sacrifice a permanent)"),
|
||||
new SpelltitheEnforcerEffect(),
|
||||
new FilterSpell(),
|
||||
false,
|
||||
SetTargetPointer.PLAYER
|
||||
|
@ -88,87 +77,32 @@ public class SpelltitheEnforcer extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class DoUnlessTargetPaysEffect extends OneShotEffect {
|
||||
protected Effects executingEffects = new Effects();
|
||||
private final Cost cost;
|
||||
private String chooseUseText;
|
||||
class SpelltitheEnforcerEffect extends SacrificeEffect {
|
||||
|
||||
public DoUnlessTargetPaysEffect(Effect effect, Cost cost) {
|
||||
this(effect, cost, null);
|
||||
SpelltitheEnforcerEffect() {
|
||||
super(new FilterPermanent("permanent to sacrifice"), 1, "that player");
|
||||
this.staticText = "that player sacrifices a permanent unless he or she pays {1}";
|
||||
}
|
||||
|
||||
public DoUnlessTargetPaysEffect(Effect effect, Cost cost, String chooseUseText) {
|
||||
super(Outcome.Benefit);
|
||||
this.executingEffects.add(effect);
|
||||
this.cost = cost;
|
||||
this.chooseUseText = chooseUseText;
|
||||
}
|
||||
|
||||
public DoUnlessTargetPaysEffect(final DoUnlessTargetPaysEffect effect) {
|
||||
SpelltitheEnforcerEffect(final SpelltitheEnforcerEffect effect) {
|
||||
super(effect);
|
||||
this.executingEffects = effect.executingEffects.copy();
|
||||
this.cost = effect.cost.copy();
|
||||
this.chooseUseText = effect.chooseUseText;
|
||||
}
|
||||
|
||||
public void addEffect(Effect effect) {
|
||||
executingEffects.add(effect);
|
||||
@Override
|
||||
public SpelltitheEnforcerEffect copy() {
|
||||
return new SpelltitheEnforcerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null && targetPlayer != null) {
|
||||
String message;
|
||||
if (chooseUseText == null) {
|
||||
String effectText = executingEffects.getText(source.getModes().getMode());
|
||||
message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?";
|
||||
} else {
|
||||
message = chooseUseText;
|
||||
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
GenericManaCost cost = new GenericManaCost(1);
|
||||
if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
|
||||
super.apply(game, source);
|
||||
}
|
||||
message = CardUtil.replaceSourceName(message, sourceObject.getLogName());
|
||||
boolean result = true;
|
||||
boolean doEffect = true;
|
||||
// check if target player is willing to pay
|
||||
if (cost.canPay(source, source.getSourceId(), targetPlayer.getId(), game) && targetPlayer.chooseUse(Outcome.Detriment, message, game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), targetPlayer.getId(), false)) {
|
||||
game.informPlayers(targetPlayer.getName() + " pays the cost to prevent the effect");
|
||||
doEffect = false;
|
||||
}
|
||||
}
|
||||
// do the effects player did not pay
|
||||
if (doEffect) {
|
||||
for(Effect effect: executingEffects) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
if (!(effect instanceof PostResolveEffect)) {
|
||||
result &= effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
String effectsText = executingEffects.getText(mode);
|
||||
return effectsText.substring(0, effectsText.length() -1) + " unless he or she pays " + cost.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoUnlessTargetPaysEffect copy() {
|
||||
return new DoUnlessTargetPaysEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.sets.invasion;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.sets.journeyintonyx;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
package mage.sets.journeyintonyx;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.turn.ControlTargetPlayerNextTurnEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.Zone;
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.common.DrawCardTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.Rarity;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.Outcome;
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect.HandSizeModification;
|
||||
import mage.cards.Card;
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.sets.mirrodinbesieged;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.MageInt;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.modernmasters;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
|
@ -39,10 +38,8 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -59,7 +56,6 @@ public class PetalsOfInsight extends CardImpl {
|
|||
|
||||
// Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards.
|
||||
this.getSpellAbility().addEffect(new PetalsOfInsightEffect());
|
||||
this.getSpellAbility().addEffect(new PetalsOfInsightReturnEffect());
|
||||
}
|
||||
|
||||
public PetalsOfInsight(final PetalsOfInsight card) {
|
||||
|
@ -74,12 +70,12 @@ public class PetalsOfInsight extends CardImpl {
|
|||
|
||||
class PetalsOfInsightEffect extends OneShotEffect {
|
||||
|
||||
public PetalsOfInsightEffect() {
|
||||
PetalsOfInsightEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Look at the top three cards of your library. You may put those cards on the bottom of your library in any order";
|
||||
this.staticText = "Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return {this} to its owner's hand. Otherwise, draw three cards";
|
||||
}
|
||||
|
||||
public PetalsOfInsightEffect(final PetalsOfInsightEffect effect) {
|
||||
PetalsOfInsightEffect(final PetalsOfInsightEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -94,32 +90,21 @@ class PetalsOfInsightEffect extends OneShotEffect {
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
Cards cards = new CardsImpl();
|
||||
int count = Math.min(player.getLibrary().size(), 3);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
game.setZone(card.getId(), Zone.PICK);
|
||||
}
|
||||
}
|
||||
player.lookAtCards("Petals of Insight", cards, game);
|
||||
if (player.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", game)) {
|
||||
TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library"));
|
||||
while (player.isInGame() && cards.size() > 1) {
|
||||
player.choose(Outcome.Neutral, cards, target, game);
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
|
||||
player.putCardsOnBottomOfLibrary(cards, game, source, true);
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
if (cards.size() == 1) {
|
||||
Card card = cards.get(cards.iterator().next(), game);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
|
||||
}
|
||||
game.getState().setValue(source.getSourceId().toString(), Boolean.TRUE);
|
||||
} else {
|
||||
for (UUID cardId: cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
|
@ -127,43 +112,8 @@ class PetalsOfInsightEffect extends OneShotEffect {
|
|||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
}
|
||||
}
|
||||
game.getState().setValue(source.getSourceId().toString(), Boolean.FALSE);
|
||||
player.drawCards(3, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class PetalsOfInsightReturnEffect extends PostResolveEffect {
|
||||
|
||||
public PetalsOfInsightReturnEffect() {
|
||||
staticText = "If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards";
|
||||
}
|
||||
|
||||
public PetalsOfInsightReturnEffect(final PetalsOfInsightReturnEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PetalsOfInsightReturnEffect copy() {
|
||||
return new PetalsOfInsightReturnEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
Boolean returnToHand = (Boolean) game.getState().getValue(source.getSourceId().toString());
|
||||
if (returnToHand == null) {
|
||||
returnToHand = Boolean.FALSE;
|
||||
}
|
||||
if (returnToHand) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
}
|
||||
else {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
controller.drawCards(3, game);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.sets.morningtide;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ClashWinReturnToHandSpellEffect;
|
||||
import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
|
|
@ -27,22 +27,13 @@
|
|||
*/
|
||||
package mage.sets.morningtide;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.ClashEffect;
|
||||
import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ClashWinReturnToHandSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,17 +29,10 @@ package mage.sets.planarchaos;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.PutOnLibrarySourceEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -50,7 +43,6 @@ import mage.filter.common.FilterControlledLandPermanent;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,13 +61,7 @@ public class ShivanWumpus extends CardImpl {
|
|||
this.addAbility(TrampleAbility.getInstance());
|
||||
|
||||
// When Shivan Wumpus enters the battlefield, any player may sacrifice a land. If a player does, put Shivan Wumpus on top of its owner's library.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(
|
||||
new DoIfAnyPlayerPaysEffect(
|
||||
new PutOnLibrarySourceEffect(true),
|
||||
new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent("a land"))),
|
||||
"Sacrifice a land to return {this} to top of its owners library?"),
|
||||
false
|
||||
));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new ShivanWumpusEffect(), false));
|
||||
}
|
||||
|
||||
public ShivanWumpus(final ShivanWumpus card) {
|
||||
|
@ -88,91 +74,42 @@ public class ShivanWumpus extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class DoIfAnyPlayerPaysEffect extends OneShotEffect {
|
||||
protected Effects executingEffects = new Effects();
|
||||
private final Cost cost;
|
||||
private String chooseUseText;
|
||||
class ShivanWumpusEffect extends PutOnLibrarySourceEffect {
|
||||
|
||||
public DoIfAnyPlayerPaysEffect(Effect effect, Cost cost) {
|
||||
this(effect, cost, null);
|
||||
ShivanWumpusEffect() {
|
||||
super(true);
|
||||
this.staticText = "any player may sacrifice a land. If a player does, put {this} on top of its owner's library";
|
||||
}
|
||||
|
||||
public DoIfAnyPlayerPaysEffect(Effect effect, Cost cost, String chooseUseText) {
|
||||
super(Outcome.Benefit);
|
||||
this.executingEffects.add(effect);
|
||||
this.cost = cost;
|
||||
this.chooseUseText = chooseUseText;
|
||||
}
|
||||
|
||||
public DoIfAnyPlayerPaysEffect(final DoIfAnyPlayerPaysEffect effect) {
|
||||
ShivanWumpusEffect(final ShivanWumpusEffect effect) {
|
||||
super(effect);
|
||||
this.executingEffects = effect.executingEffects.copy();
|
||||
this.cost = effect.cost.copy();
|
||||
this.chooseUseText = effect.chooseUseText;
|
||||
}
|
||||
|
||||
public void addEffect(Effect effect) {
|
||||
executingEffects.add(effect);
|
||||
@Override
|
||||
public ShivanWumpusEffect copy() {
|
||||
return new ShivanWumpusEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
String message;
|
||||
if (chooseUseText == null) {
|
||||
String effectText = executingEffects.getText(source.getModes().getMode());
|
||||
message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?";
|
||||
} else {
|
||||
message = chooseUseText;
|
||||
}
|
||||
message = CardUtil.replaceSourceName(message, sourceObject.getLogName());
|
||||
boolean result = true;
|
||||
boolean doEffect = false;
|
||||
// check if any player is willing to pay
|
||||
if (controller != null) {
|
||||
boolean costPaid = false;
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent()));
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Detriment, message, game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + player.getName() + " pays the cost");
|
||||
doEffect = true;
|
||||
break;
|
||||
if (player != null
|
||||
&& cost.canPay(source, source.getSourceId(), playerId, game)
|
||||
&& player.chooseUse(Outcome.Sacrifice, "Sacrifice a land?", game)
|
||||
&& cost.pay(source, game, source.getSourceId(), playerId, true)) {
|
||||
costPaid = true;
|
||||
}
|
||||
}
|
||||
if (costPaid) {
|
||||
super.apply(game, source);
|
||||
}
|
||||
// do the effects if nobody paid
|
||||
if (doEffect) {
|
||||
for(Effect effect: executingEffects) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
if (!(effect instanceof PostResolveEffect)) {
|
||||
result &= effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
// any player may sacrifice a land. If a player does, put Shivan Wumpus on top of its owner's library.
|
||||
String effectsText = executingEffects.getText(mode);
|
||||
return "any player may " + cost.getText() + ". If a player does, " + effectsText.substring(0, effectsText.length() -1) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoIfAnyPlayerPaysEffect copy() {
|
||||
return new DoIfAnyPlayerPaysEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.sets.planechase;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.sets.returntoravnica;
|
|||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
|
|
@ -27,17 +27,17 @@
|
|||
*/
|
||||
package mage.sets.scarsofmirrodin;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -45,8 +45,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -57,9 +55,10 @@ public class CerebralEruption extends CardImpl {
|
|||
super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}");
|
||||
this.expansionSetCode = "SOM";
|
||||
this.color.setRed(true);
|
||||
|
||||
// Target opponent reveals the top card of his or her library. Cerebral Eruption deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return Cerebral Eruption to its owner's hand.
|
||||
this.getSpellAbility().addTarget(new TargetOpponent());
|
||||
this.getSpellAbility().addEffect(new CerebralEruptionEffect1());
|
||||
this.getSpellAbility().addEffect(new CerebralEruptionEffect2());
|
||||
this.getSpellAbility().addEffect(new CerebralEruptionEffect());
|
||||
}
|
||||
|
||||
public CerebralEruption(final CerebralEruption card) {
|
||||
|
@ -70,19 +69,18 @@ public class CerebralEruption extends CardImpl {
|
|||
public CerebralEruption copy() {
|
||||
return new CerebralEruption(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CerebralEruptionEffect1 extends OneShotEffect {
|
||||
class CerebralEruptionEffect extends OneShotEffect {
|
||||
|
||||
private static FilterPermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
public CerebralEruptionEffect1() {
|
||||
CerebralEruptionEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Target opponent reveals the top card of his or her library. {this} deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls.";
|
||||
staticText = "Target opponent reveals the top card of his or her library. {this} deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public CerebralEruptionEffect1(final CerebralEruptionEffect1 effect) {
|
||||
CerebralEruptionEffect(final CerebralEruptionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -100,42 +98,19 @@ class CerebralEruptionEffect1 extends OneShotEffect {
|
|||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
|
||||
perm.damage(damage, source.getSourceId(), game, false, true);
|
||||
}
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CerebralEruptionEffect1 copy() {
|
||||
return new CerebralEruptionEffect1(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CerebralEruptionEffect2 extends PostResolveEffect {
|
||||
|
||||
public CerebralEruptionEffect2() {
|
||||
staticText = "If a land card is revealed this way, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public CerebralEruptionEffect2(final CerebralEruptionEffect2 effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Card revealed = (Card) game.getState().getValue(source.getSourceId().toString());
|
||||
if (revealed != null && revealed.getCardType().contains(CardType.LAND)) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
}
|
||||
else {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
public CerebralEruptionEffect copy() {
|
||||
return new CerebralEruptionEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CerebralEruptionEffect2 copy() {
|
||||
return new CerebralEruptionEffect2(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,19 +28,17 @@
|
|||
package mage.sets.scarsofmirrodin;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetDiscard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -52,10 +50,10 @@ public class PsychicMiasma extends CardImpl {
|
|||
super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}");
|
||||
this.expansionSetCode = "SOM";
|
||||
this.color.setBlack(true);
|
||||
|
||||
// Target player discards a card. If a land card is discarded this way, return Psychic Miasma to its owner's hand.
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
PsychicMiasmaEffect1 effect1 = new PsychicMiasmaEffect1();
|
||||
this.getSpellAbility().addEffect(effect1);
|
||||
this.getSpellAbility().addEffect(new PsychicMiasmaEffect2());
|
||||
this.getSpellAbility().addEffect(new PsychicMiasmaEffect());
|
||||
}
|
||||
|
||||
public PsychicMiasma(final PsychicMiasma card) {
|
||||
|
@ -69,14 +67,14 @@ public class PsychicMiasma extends CardImpl {
|
|||
|
||||
}
|
||||
|
||||
class PsychicMiasmaEffect1 extends OneShotEffect {
|
||||
class PsychicMiasmaEffect extends OneShotEffect {
|
||||
|
||||
public PsychicMiasmaEffect1() {
|
||||
PsychicMiasmaEffect() {
|
||||
super(Outcome.Discard);
|
||||
staticText = "Target player discards a card";
|
||||
staticText = "Target player discards a card. If a land card is discarded this way, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public PsychicMiasmaEffect1(final PsychicMiasmaEffect1 effect) {
|
||||
PsychicMiasmaEffect(final PsychicMiasmaEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -84,49 +82,19 @@ class PsychicMiasmaEffect1 extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
TargetDiscard target = new TargetDiscard(player.getId());
|
||||
player.choose(Outcome.Discard, target, source.getSourceId(), game);
|
||||
Card card = player.getHand().get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.discard(card, source, game);
|
||||
game.getState().setValue(source.getSourceId().toString(), card);
|
||||
return true;
|
||||
Card discardedCard = player.discardOne(false, source, game);
|
||||
if (discardedCard != null && discardedCard.getCardType().contains(CardType.LAND)) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsychicMiasmaEffect1 copy() {
|
||||
return new PsychicMiasmaEffect1(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PsychicMiasmaEffect2 extends PostResolveEffect {
|
||||
|
||||
public PsychicMiasmaEffect2() {
|
||||
staticText = "If a land card is discarded this way, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public PsychicMiasmaEffect2(final PsychicMiasmaEffect2 effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsychicMiasmaEffect2 copy() {
|
||||
return new PsychicMiasmaEffect2(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Card discard = (Card) game.getState().getValue(source.getSourceId().toString());
|
||||
if (discard != null && discard.getCardType().contains(CardType.LAND)) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
}
|
||||
else {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
public PsychicMiasmaEffect copy() {
|
||||
return new PsychicMiasmaEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -28,17 +28,11 @@
|
|||
package mage.sets.shadowmoor;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.discard.DiscardHandTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -46,7 +40,6 @@ import mage.constants.Rarity;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,7 +55,7 @@ public class Tyrannize extends CardImpl {
|
|||
|
||||
// Target player discards his or her hand unless he or she pays 7 life.
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
this.getSpellAbility().addEffect(new DoUnlessTargetPaysEffect(new DiscardHandTargetEffect(), new PayLifeCost(7), rule));
|
||||
this.getSpellAbility().addEffect(new TyrannizeEffect());
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,87 +69,36 @@ public class Tyrannize extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class DoUnlessTargetPaysEffect extends OneShotEffect {
|
||||
protected Effects executingEffects = new Effects();
|
||||
private final Cost cost;
|
||||
private String chooseUseText;
|
||||
class TyrannizeEffect extends OneShotEffect {
|
||||
|
||||
public DoUnlessTargetPaysEffect(Effect effect, Cost cost) {
|
||||
this(effect, cost, null);
|
||||
TyrannizeEffect() {
|
||||
super(Outcome.Discard);
|
||||
this.staticText = "Target player discards his or her hand unless he or she pays 7 life";
|
||||
}
|
||||
|
||||
public DoUnlessTargetPaysEffect(Effect effect, Cost cost, String chooseUseText) {
|
||||
super(Outcome.Benefit);
|
||||
this.executingEffects.add(effect);
|
||||
this.cost = cost;
|
||||
this.chooseUseText = chooseUseText;
|
||||
}
|
||||
|
||||
public DoUnlessTargetPaysEffect(final DoUnlessTargetPaysEffect effect) {
|
||||
TyrannizeEffect(final TyrannizeEffect effect) {
|
||||
super(effect);
|
||||
this.executingEffects = effect.executingEffects.copy();
|
||||
this.cost = effect.cost.copy();
|
||||
this.chooseUseText = effect.chooseUseText;
|
||||
}
|
||||
|
||||
public void addEffect(Effect effect) {
|
||||
executingEffects.add(effect);
|
||||
@Override
|
||||
public TyrannizeEffect copy() {
|
||||
return new TyrannizeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null && targetPlayer != null) {
|
||||
String message;
|
||||
if (chooseUseText == null) {
|
||||
String effectText = executingEffects.getText(source.getModes().getMode());
|
||||
message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?";
|
||||
} else {
|
||||
message = chooseUseText;
|
||||
}
|
||||
message = CardUtil.replaceSourceName(message, sourceObject.getLogName());
|
||||
boolean result = true;
|
||||
boolean doEffect = true;
|
||||
// check if target player is willing to pay
|
||||
if (cost.canPay(source, source.getSourceId(), targetPlayer.getId(), game) && targetPlayer.chooseUse(Outcome.Detriment, message, game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), targetPlayer.getId(), false)) {
|
||||
game.informPlayers(targetPlayer.getName() + " pays the cost to prevent the effect");
|
||||
doEffect = false;
|
||||
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
Cost cost = new PayLifeCost(7);
|
||||
if (!cost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||
|| !player.chooseUse(Outcome.LoseLife, "Pay 7 life?", game)
|
||||
|| !cost.pay(source, game, source.getSourceId(), player.getId(), true)) {
|
||||
for (Card card : player.getHand().getCards(game)) {
|
||||
player.discard(card, source, game);
|
||||
}
|
||||
}
|
||||
// do the effects player did not pay
|
||||
if (doEffect) {
|
||||
for(Effect effect: executingEffects) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
if (!(effect instanceof PostResolveEffect)) {
|
||||
result &= effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
String effectsText = executingEffects.getText(mode);
|
||||
return effectsText.substring(0, effectsText.length() -1) + " unless he or she pays " + cost.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoUnlessTargetPaysEffect copy() {
|
||||
return new DoUnlessTargetPaysEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.abilities.costs.Cost;
|
|||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.*;
|
||||
|
|
|
@ -31,7 +31,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.costs.common.DiscardXTargetCost;
|
||||
import mage.abilities.dynamicvalue.common.GetXValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.sets.urzassaga;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.discard.DiscardHandAllEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.postresolve.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.UntapLandsEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
|
|
|
@ -50,7 +50,6 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.abilities.effects.common.DynamicManaEffect;
|
||||
import mage.abilities.keyword.FlashbackAbility;
|
||||
|
@ -195,7 +194,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (checkIfClause(game)) {
|
||||
for (Effect effect: getEffects()) {
|
||||
if (effect instanceof OneShotEffect) {
|
||||
if (!(effect instanceof PostResolveEffect)) {
|
||||
boolean effectResult = effect.apply(game, this);
|
||||
result &= effectResult;
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
@ -212,7 +210,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) effect, this);
|
||||
}
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 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;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class PostResolveEffect extends OneShotEffect {
|
||||
|
||||
public PostResolveEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
public PostResolveEffect(final PostResolveEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isActive(Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract void postResolve(Card card, Ability source, UUID controllerId, Game game);
|
||||
|
||||
}
|
|
@ -25,15 +25,13 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.postresolve;
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.ClashEffect;
|
||||
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;
|
||||
|
@ -42,42 +40,36 @@ import mage.players.Player;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ClashWinReturnToHandSpellEffect extends PostResolveEffect implements MageSingleton {
|
||||
public class ClashWinReturnToHandSpellEffect extends OneShotEffect implements MageSingleton {
|
||||
|
||||
private static final ClashWinReturnToHandSpellEffect fINSTANCE = new ClashWinReturnToHandSpellEffect();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ClashWinReturnToHandSpellEffect() {
|
||||
staticText = "Clash with an opponent. If you win, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public static ClashWinReturnToHandSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
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.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClashWinReturnToHandSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(Ability source, Game game) {
|
||||
return ClashEffect.getInstance().apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,6 @@ import mage.abilities.Mode;
|
|||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
@ -91,10 +90,8 @@ public class DoIfClashWonEffect extends OneShotEffect {
|
|||
executingEffect.setTargetPointer(this.targetPointer);
|
||||
}
|
||||
if (executingEffect instanceof OneShotEffect) {
|
||||
if (!(executingEffect instanceof PostResolveEffect)) {
|
||||
return executingEffect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) executingEffect, source);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
@ -61,10 +60,8 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
for(Effect effect: executingEffects) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
if (!(effect instanceof PostResolveEffect)) {
|
||||
result &= effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
@ -106,10 +105,8 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
|
|||
for(Effect effect: executingEffects) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
if (!(effect instanceof PostResolveEffect)) {
|
||||
result &= effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
|
|
|
@ -26,49 +26,49 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.postresolve;
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.util.UUID;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ExileSpellEffect extends PostResolveEffect implements MageSingleton {
|
||||
public class ExileSpellEffect extends OneShotEffect implements MageSingleton {
|
||||
|
||||
private static final ExileSpellEffect fINSTANCE = new ExileSpellEffect();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
public static ExileSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ExileSpellEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "Exile {this}";
|
||||
}
|
||||
|
||||
public static ExileSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", controllerId, game, Zone.STACK);
|
||||
}
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
controller.moveCardToExileWithInfo(spellCard, null, "", source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
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 Loki
|
||||
*/
|
||||
public class ReturnToHandSpellEffect extends OneShotEffect implements MageSingleton {
|
||||
|
||||
private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect();
|
||||
|
||||
public static ReturnToHandSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ReturnToHandSpellEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnToHandSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
}
|
|
@ -25,12 +25,12 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.postresolve;
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
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;
|
||||
|
@ -39,11 +39,12 @@ import mage.players.Player;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ReturnToLibrarySpellEffect extends PostResolveEffect {
|
||||
public class ReturnToLibrarySpellEffect extends OneShotEffect {
|
||||
|
||||
private final boolean toTop;
|
||||
|
||||
public ReturnToLibrarySpellEffect(boolean top) {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "Put {this} on "+ (top ? "top":"the bottom") + " of its owner's library";
|
||||
this.toTop = top;
|
||||
}
|
||||
|
@ -55,19 +56,19 @@ public class ReturnToLibrarySpellEffect extends PostResolveEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, toTop, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnToLibrarySpellEffect copy() {
|
||||
return new ReturnToLibrarySpellEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.STACK, toTop, true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,56 +26,53 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.postresolve;
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
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;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class ShuffleSpellEffect extends PostResolveEffect implements MageSingleton {
|
||||
public class ShuffleSpellEffect extends OneShotEffect implements MageSingleton {
|
||||
|
||||
private static final ShuffleSpellEffect fINSTANCE = new ShuffleSpellEffect();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ShuffleSpellEffect() {
|
||||
staticText = "Shuffle {this} into its owner's library";
|
||||
}
|
||||
|
||||
public static ShuffleSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ShuffleSpellEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "Shuffle {this} into its owner's library";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
|
||||
if (spellCard != null) {
|
||||
Player owner = game.getPlayer(spellCard.getOwnerId());
|
||||
if (owner != null) {
|
||||
controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, true, true);
|
||||
owner.shuffleLibrary(game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShuffleSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (controller != null && owner != null) {
|
||||
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.STACK, true, true);
|
||||
owner.shuffleLibrary(game);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package mage.abilities.effects.postresolve;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.util.UUID;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public class ReturnToHandSpellEffect extends PostResolveEffect implements MageSingleton {
|
||||
private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ReturnToHandSpellEffect() {
|
||||
staticText = "Return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public static ReturnToHandSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnToHandSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,8 +44,6 @@ import mage.abilities.costs.Cost;
|
|||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.keyword.BestowAbility;
|
||||
import mage.abilities.keyword.MorphAbility;
|
||||
import mage.cards.Card;
|
||||
|
@ -64,7 +62,6 @@ import mage.game.permanent.PermanentCard;
|
|||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetAmount;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -204,19 +201,9 @@ public class Spell implements StackObject, Card {
|
|||
index++;
|
||||
}
|
||||
}
|
||||
if (!isCopiedSpell()) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof PostResolveEffect) {
|
||||
if (((PostResolveEffect) effect).isActive(ability, game)) {
|
||||
((PostResolveEffect) effect).postResolve(card, ability, controllerId, game);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (game.getState().getZone(card.getMainCard().getId()) == Zone.STACK) {
|
||||
card.moveToZone(Zone.GRAVEYARD, ability.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//20091005 - 608.2b
|
||||
|
|
Loading…
Reference in a new issue