Some clean up changes.

This commit is contained in:
LevelX2 2016-10-02 17:27:05 +02:00
parent 5469facdd6
commit 5d94ed8dd0
43 changed files with 187 additions and 343 deletions

View file

@ -601,7 +601,7 @@ public class TableController {
ServerMessagesUtil.getInstance().incGamesStarted(); ServerMessagesUtil.getInstance().incGamesStarted();
// log about game started // log about game started
logger.info("GAME started " + match.getGame().getId() + " [" + match.getName() + "] " + creator + " - " + opponent.toString()); logger.info("GAME started " + (match.getGame() != null ? match.getGame().getId() : "no Game") + " [" + match.getName() + "] " + creator + " - " + opponent.toString());
logger.debug("- matchId: " + match.getId() + " [" + match.getName() + "]"); logger.debug("- matchId: " + match.getId() + " [" + match.getName() + "]");
if (match.getGame() != null) { if (match.getGame() != null) {
logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId())); logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId()));

View file

@ -60,7 +60,7 @@ public class CoastalDrake extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// {1}{U}, {T} : Return target Kavu to its owner's hand. // {1}{U}, {T} : Return target Kavu to its owner's hand.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(true), new ManaCostsImpl("{1}{U}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(), new ManaCostsImpl("{1}{U}"));
ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("Kavu", "Kavu"))); ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("Kavu", "Kavu")));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);

View file

@ -46,7 +46,7 @@ public class ClutchOfCurrents extends CardImpl {
this.expansionSetCode = "BFZ"; this.expansionSetCode = "BFZ";
// Return target creature to its owner's hand. // Return target creature to its owner's hand.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true, false)); this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(false));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// Awaken 3{4}{U} // Awaken 3{4}{U}

View file

@ -121,10 +121,7 @@ class GoryosVengeanceEffect extends OneShotEffect {
Effect exileEffect = new ExileTargetEffect("Exile " + permanent.getName() + " at the beginning of the next end step"); Effect exileEffect = new ExileTargetEffect("Exile " + permanent.getName() + " at the beginning of the next end step");
exileEffect.setTargetPointer(new FixedTarget(permanent, game)); exileEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId()); game.addDelayedTriggeredAbility(delayedAbility, source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }

View file

@ -30,7 +30,6 @@ package mage.sets.championsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
@ -118,11 +117,7 @@ class KikiJikiMirrorBreakerEffect extends OneShotEffect {
for (Permanent addedToken : effect.getAddedPermanent()) { for (Permanent addedToken : effect.getAddedPermanent()) {
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId()); SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(addedToken.getId())); sacrificeEffect.setTargetPointer(new FixedTarget(addedToken.getId()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
return true; return true;
} }

View file

@ -103,10 +103,7 @@ class OtherworldlyJourneyEffect extends OneShotEffect {
//create delayed triggered ability //create delayed triggered ability
DelayedTriggeredAbility delayedAbility DelayedTriggeredAbility delayedAbility
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OtherworldlyJourneyReturnFromExileEffect(new MageObjectReference(card, game))); = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OtherworldlyJourneyReturnFromExileEffect(new MageObjectReference(card, game)));
delayedAbility.setSourceId(source.getSourceId()); game.addDelayedTriggeredAbility(delayedAbility, source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;
@ -198,4 +195,4 @@ class OtherworldlyJourneyEntersBattlefieldEffect extends ReplacementEffectImpl {
public OtherworldlyJourneyEntersBattlefieldEffect copy() { public OtherworldlyJourneyEntersBattlefieldEffect copy() {
return new OtherworldlyJourneyEntersBattlefieldEffect(this); return new OtherworldlyJourneyEntersBattlefieldEffect(this);
} }
} }

View file

@ -29,7 +29,6 @@ package mage.sets.commander2014;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CanBeYourCommanderAbility; import mage.abilities.common.CanBeYourCommanderAbility;
@ -247,11 +246,7 @@ class DarettiScrapSavantEffect extends OneShotEffect {
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
effect.setText("return that card to the battlefield at the beginning of the next end step"); effect.setText("return that card to the battlefield at the beginning of the next end step");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;

View file

@ -33,9 +33,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -97,12 +95,8 @@ class SyntheticDestinyEffect extends OneShotEffect {
cardsToExile.addAll(game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), controller.getId(), game)); cardsToExile.addAll(game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), controller.getId(), game));
controller.moveCards(cardsToExile, Zone.EXILED, source, game); controller.moveCards(cardsToExile, Zone.EXILED, source, game);
//Delayed ability //Delayed ability
Effect effect = new SyntheticDestinyDelayedEffect(cardsToExile.size()); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); new SyntheticDestinyDelayedEffect(cardsToExile.size())), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }

View file

@ -30,7 +30,6 @@ package mage.sets.conflux;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksTriggeredAbility; import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -97,11 +96,7 @@ class BrackwaterElementalSacrificeEffect extends OneShotEffect {
if (sourcePermanent != null) { if (sourcePermanent != null) {
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice {this}"); SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice {this}");
sacrificeEffect.setTargetPointer(new FixedTarget(sourcePermanent.getId())); sacrificeEffect.setTargetPointer(new FixedTarget(sourcePermanent.getId()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
return false; return false;
} }

View file

@ -29,7 +29,6 @@ package mage.sets.darksteel;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.dynamicvalue.common.AttackingCreatureCount; import mage.abilities.dynamicvalue.common.AttackingCreatureCount;
@ -100,11 +99,7 @@ class TearsOfRageEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId()); Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId());
effect.setTargetPointer(new FixedTargets(game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(), controller.getId(), game), game)); effect.setTargetPointer(new FixedTargets(game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(), controller.getId(), game), game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;

View file

@ -29,7 +29,6 @@ package mage.sets.dragonsoftarkir;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.AttacksAttachedTriggeredAbility; import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -111,11 +110,7 @@ class MirrorMockeryEffect extends OneShotEffect {
if (addedToken != null) { if (addedToken != null) {
ExileTargetEffect exileEffect = new ExileTargetEffect(); ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(addedToken, game)); exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
DelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect); game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;

View file

@ -68,7 +68,7 @@ public class CropSigil extends CardImpl {
// <i>Delirium</i> &mdash; {2}{G}, Sacrifice Crop Sigil: Return up to one target creature card and up to one target land card from your graveyard to your hand. // <i>Delirium</i> &mdash; {2}{G}, Sacrifice Crop Sigil: Return up to one target creature card and up to one target land card from your graveyard to your hand.
// Activate this ability only if there are four or more card types among cards in your graveyard. // Activate this ability only if there are four or more card types among cards in your graveyard.
Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(true, true), new ManaCostsImpl<>("{2}{G}"), Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(true), new ManaCostsImpl<>("{2}{G}"),
DeliriumCondition.getInstance(), DeliriumCondition.getInstance(),
"<i>Delirium</i> &mdash; {2}{G}, Sacrifice {this}: Return up to one target creature card and up to one target land card from your graveyard to your hand. " "<i>Delirium</i> &mdash; {2}{G}, Sacrifice {this}: Return up to one target creature card and up to one target land card from your graveyard to your hand. "
+ "Activate this ability only if there are four or more card types among cards in your graveyard"); + "Activate this ability only if there are four or more card types among cards in your graveyard");

View file

@ -147,11 +147,8 @@ class IdentityThiefEffect extends OneShotEffect {
// Copy exiled permanent // Copy exiled permanent
game.addEffect(copyEffect, source); game.addEffect(copyEffect, source);
// Create delayed triggered ability // Create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
delayedAbility.setSourceId(source.getSourceId()); new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)), source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -30,7 +30,6 @@ package mage.sets.eldritchmoon;
import java.util.UUID; import java.util.UUID;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
@ -101,12 +100,8 @@ class LongRoadHomeEffect extends OneShotEffect {
Card card = game.getCard(permanent.getId()); Card card = game.getCard(permanent.getId());
if (card != null) { if (card != null) {
//create delayed triggered ability //create delayed triggered ability
DelayedTriggeredAbility delayedAbility game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LongRoadHomeReturnFromExileEffect(new MageObjectReference(card, game))); new LongRoadHomeReturnFromExileEffect(new MageObjectReference(card, game))), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;
@ -152,8 +147,7 @@ class LongRoadHomeReturnFromExileEffect extends OneShotEffect {
MeldCard meldCard = (MeldCard) card; MeldCard meldCard = (MeldCard) card;
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getTopHalfCard(), game)), source); game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getTopHalfCard(), game)), source);
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getBottomHalfCard(), game)), source); game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getBottomHalfCard(), game)), source);
} } else {
else {
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source); game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source);
} }
owner.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null); owner.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
@ -205,4 +199,4 @@ class LongRoadHomeEntersBattlefieldEffect extends ReplacementEffectImpl {
public LongRoadHomeEntersBattlefieldEffect copy() { public LongRoadHomeEntersBattlefieldEffect copy() {
return new LongRoadHomeEntersBattlefieldEffect(this); return new LongRoadHomeEntersBattlefieldEffect(this);
} }
} }

View file

@ -90,11 +90,7 @@ class OtherworldlyOutburstEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
DelayedTriggeredAbility delayedAbility = new OtherworldlyOutburstDelayedTriggeredAbility(source.getFirstTarget()); game.addDelayedTriggeredAbility(new OtherworldlyOutburstDelayedTriggeredAbility(source.getFirstTarget()), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -28,10 +28,6 @@
package mage.sets.eventide; package mage.sets.eventide;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -40,6 +36,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileEffect; import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
@ -53,12 +53,12 @@ import mage.target.TargetPermanent;
*/ */
public class Flickerwisp extends CardImpl { public class Flickerwisp extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("another target permanent"); private static final FilterPermanent filter = new FilterPermanent("another target permanent");
static{ static {
filter.add(new AnotherPredicate()); filter.add(new AnotherPredicate());
} }
public Flickerwisp(UUID ownerId) { public Flickerwisp(UUID ownerId) {
super(ownerId, 6, "Flickerwisp", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); super(ownerId, 6, "Flickerwisp", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}{W}");
this.expansionSetCode = "EVE"; this.expansionSetCode = "EVE";
@ -69,7 +69,7 @@ public class Flickerwisp extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// When Flickerwisp enters the battlefield, exile another target permanent. Return that card to the battlefield under its owner's control at the beginning of the next end step. // When Flickerwisp enters the battlefield, exile another target permanent. Return that card to the battlefield under its owner's control at the beginning of the next end step.
Ability ability = new EntersBattlefieldTriggeredAbility(new FlickerwispEffect()); Ability ability = new EntersBattlefieldTriggeredAbility(new FlickerwispEffect());
ability.addTarget(new TargetPermanent(filter)); ability.addTarget(new TargetPermanent(filter));
@ -105,11 +105,8 @@ class FlickerwispEffect extends OneShotEffect {
if (controller != null && permanent != null && sourcePermanent != null) { if (controller != null && permanent != null && sourcePermanent != null) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
//create delayed triggered ability //create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
delayedAbility.setSourceId(source.getSourceId()); new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)), source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }
@ -120,4 +117,4 @@ class FlickerwispEffect extends OneShotEffect {
public FlickerwispEffect copy() { public FlickerwispEffect copy() {
return new FlickerwispEffect(this); return new FlickerwispEffect(this);
} }
} }

View file

@ -58,7 +58,7 @@ public class VenserShaperSavant extends CardImpl {
// Flash // Flash
this.addAbility(FlashAbility.getInstance()); this.addAbility(FlashAbility.getInstance());
// When Venser, Shaper Savant enters the battlefield, return target spell or permanent to its owner's hand. // When Venser, Shaper Savant enters the battlefield, return target spell or permanent to its owner's hand.
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(true), false); Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), false);
Target target = new TargetSpellOrPermanent(); Target target = new TargetSpellOrPermanent();
ability.addTarget(target); ability.addTarget(target);
this.addAbility(ability); this.addAbility(ability);

View file

@ -92,12 +92,8 @@ class VoidwalkEffect extends OneShotEffect {
if (permanent != null) { if (permanent != null) {
int zcc = game.getState().getZoneChangeCounter(permanent.getId()); int zcc = game.getState().getZoneChangeCounter(permanent.getId());
if (permanent.moveToExile(null, "", source.getSourceId(), game)) { if (permanent.moveToExile(null, "", source.getSourceId(), game)) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility( game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new ReturnToBattlefieldUnderOwnerControlSourceEffect(false, zcc + 1)); new ReturnToBattlefieldUnderOwnerControlSourceEffect(false, zcc + 1)), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
} }

View file

@ -29,7 +29,6 @@ package mage.sets.iceage;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -143,14 +142,10 @@ class NecropotenceEffect extends OneShotEffect {
Card card = controller.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);
if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, false)) { if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, false)) {
card.setFaceDown(true, game); card.setFaceDown(true, game);
Effect returnToHandEffect = new ReturnToHandTargetEffect(false); Effect returnToHandEffect = new ReturnToHandTargetEffect();
returnToHandEffect.setText("put that face down card into your hand"); returnToHandEffect.setText("put that face down card into your hand");
returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;

View file

@ -116,11 +116,7 @@ class MeanderingTowershellEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null && sourcePermanent != null) { if (controller != null && sourcePermanent != null) {
controller.moveCardToExileWithInfo(sourcePermanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); controller.moveCardToExileWithInfo(sourcePermanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
DelayedTriggeredAbility delayedAbility = new AtBeginningNextDeclareAttackersStepNextTurnDelayedTriggeredAbility(); game.addDelayedTriggeredAbility(new AtBeginningNextDeclareAttackersStepNextTurnDelayedTriggeredAbility(), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;

View file

@ -30,7 +30,6 @@ package mage.sets.lorwyn;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -136,11 +135,7 @@ class IncandescentSoulstokeEffect extends OneShotEffect {
game.addEffect(effect, source); game.addEffect(effect, source);
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId()); SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game)); sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
} }

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,20 +20,14 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.magic2011; package mage.sets.magic2011;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -43,6 +37,11 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileEffect; import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterAttackingCreature; import mage.filter.common.FilterAttackingCreature;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game; import mage.game.Game;
@ -98,11 +97,8 @@ class MystifyingMazeEffect extends OneShotEffect {
if (permanent != null) { if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Mystifying Maze Exile", source.getSourceId(), game)) { if (permanent.moveToExile(source.getSourceId(), "Mystifying Maze Exile", source.getSourceId(), game)) {
//create delayed triggered ability //create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, true)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
delayedAbility.setSourceId(source.getSourceId()); new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, true)), source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -29,7 +29,6 @@ package mage.sets.magicorigins;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.DiesCreatureTriggeredAbility; import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
@ -159,11 +158,7 @@ class LilianaDefiantNecromancerEmblemEffect extends OneShotEffect {
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
effect.setText("return that card to the battlefield at the beginning of the next end step"); effect.setText("return that card to the battlefield at the beginning of the next end step");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;

View file

@ -86,11 +86,7 @@ public class RainbowVale extends CardImpl {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OpponentGainControlEffect()); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OpponentGainControlEffect()));
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;

View file

@ -28,22 +28,23 @@
package mage.sets.mirrodin; package mage.sets.mirrodin;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksTriggeredAbility; import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect; import mage.abilities.effects.common.counter.RemoveCounterTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -57,7 +58,11 @@ public class ClockworkBeetle extends CardImpl {
this.subtype.add("Insect"); this.subtype.add("Insect");
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = new MageInt(0); this.toughness = new MageInt(0);
// Clockwork Beetle enters the battlefield with two +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), "{this} enters the battlefield with two +1/+1 counters on it")); this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), "{this} enters the battlefield with two +1/+1 counters on it"));
// Whenever Clockwork Beetle attacks or blocks, remove a +1/+1 counter from it at end of combat.
this.addAbility(new AttacksOrBlocksTriggeredAbility(new ClockworkBeetleEffect(), false)); this.addAbility(new AttacksOrBlocksTriggeredAbility(new ClockworkBeetleEffect(), false));
} }
@ -72,6 +77,7 @@ public class ClockworkBeetle extends CardImpl {
} }
class ClockworkBeetleEffect extends OneShotEffect { class ClockworkBeetleEffect extends OneShotEffect {
ClockworkBeetleEffect() { ClockworkBeetleEffect() {
super(Outcome.UnboostCreature); super(Outcome.UnboostCreature);
staticText = "remove a +1/+1 counter from {this} at end of combat"; staticText = "remove a +1/+1 counter from {this} at end of combat";
@ -83,12 +89,12 @@ class ClockworkBeetleEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (p != null) { if (permanent != null) {
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance())); Effect effect = new RemoveCounterTargetEffect(CounterType.P1P1.createInstance());
ability.setSourceId(source.getSourceId()); effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
ability.setControllerId(source.getControllerId()); game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(effect), source);
game.addDelayedTriggeredAbility(ability); return true;
} }
return false; return false;
} }
@ -99,4 +105,3 @@ class ClockworkBeetleEffect extends OneShotEffect {
} }
} }

View file

@ -57,7 +57,6 @@ public class VirulentWound extends CardImpl {
super(ownerId, 57, "Virulent Wound", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{B}"); super(ownerId, 57, "Virulent Wound", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{B}");
this.expansionSetCode = "MBS"; this.expansionSetCode = "MBS";
// Put a -1/-1 counter on target creature. // Put a -1/-1 counter on target creature.
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.M1M1.createInstance(), Outcome.UnboostCreature)); this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.M1M1.createInstance(), Outcome.UnboostCreature));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -93,11 +92,7 @@ class VirulentWoundEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
DelayedTriggeredAbility delayedAbility = new VirulentWoundDelayedTriggeredAbility(source.getFirstTarget()); game.addDelayedTriggeredAbility(new VirulentWoundDelayedTriggeredAbility(source.getFirstTarget()), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -158,11 +158,7 @@ class KarnLiberatedEffect extends OneShotEffect {
game.getExile().add(exileId, sourceObject.getIdName(), card); game.getExile().add(exileId, sourceObject.getIdName(), card);
} }
} }
DelayedTriggeredAbility delayedAbility = new KarnLiberatedDelayedTriggeredAbility(exileId); game.addDelayedTriggeredAbility(new KarnLiberatedDelayedTriggeredAbility(exileId), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
game.start(null); game.start(null);
return true; return true;
} }

View file

@ -31,7 +31,6 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -67,15 +66,15 @@ public class ChandraFlamecaller extends CardImpl {
super(ownerId, 104, "Chandra, Flamecaller", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "{4}{R}{R}"); super(ownerId, 104, "Chandra, Flamecaller", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "{4}{R}{R}");
this.expansionSetCode = "OGW"; this.expansionSetCode = "OGW";
this.subtype.add("Chandra"); this.subtype.add("Chandra");
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4)); this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4));
// +1: Put two 3/1 red Elemental creature tokens with haste onto the battlefield. Exile them at the beginning of the next end step. // +1: Put two 3/1 red Elemental creature tokens with haste onto the battlefield. Exile them at the beginning of the next end step.
this.addAbility(new LoyaltyAbility(new ChandraElementalEffect(), 1)); this.addAbility(new LoyaltyAbility(new ChandraElementalEffect(), 1));
// 0: Discard all the cards in your hand, then draw that many cards plus one. // 0: Discard all the cards in your hand, then draw that many cards plus one.
this.addAbility(new LoyaltyAbility(new ChandraDrawEffect(), 0)); this.addAbility(new LoyaltyAbility(new ChandraDrawEffect(), 0));
// -X: Chandra, Flamecaller deals X damage to each creature. // -X: Chandra, Flamecaller deals X damage to each creature.
this.addAbility(new LoyaltyAbility(new DamageAllEffect(ChandraXValue.getDefault(), new FilterCreaturePermanent("creature")))); this.addAbility(new LoyaltyAbility(new DamageAllEffect(ChandraXValue.getDefault(), new FilterCreaturePermanent("creature"))));
} }
@ -117,11 +116,7 @@ class ChandraElementalEffect extends OneShotEffect {
if (tokenPermanent != null) { if (tokenPermanent != null) {
ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;
@ -172,7 +167,7 @@ class ChandraDrawEffect extends OneShotEffect {
for (Card card : cardsInHand) { for (Card card : cardsInHand) {
player.discard(card, source, game); player.discard(card, source, game);
} }
player.drawCards(amount+1, game); player.drawCards(amount + 1, game);
return true; return true;
} }
return false; return false;

View file

@ -86,10 +86,10 @@ class SweepAwayEffect extends OneShotEffect {
if (controller.chooseUse(Outcome.Neutral, "Put " + permanent.getIdName() + " on top of its owner's library (otherwise return to hand)?", source, game)) { if (controller.chooseUse(Outcome.Neutral, "Put " + permanent.getIdName() + " on top of its owner's library (otherwise return to hand)?", source, game)) {
new PutOnLibraryTargetEffect(true).apply(game, source); new PutOnLibraryTargetEffect(true).apply(game, source);
} else { } else {
new ReturnToHandTargetEffect(true).apply(game, source); new ReturnToHandTargetEffect().apply(game, source);
} }
} else { } else {
new ReturnToHandTargetEffect(true).apply(game, source); new ReturnToHandTargetEffect().apply(game, source);
} }
return true; return true;
} }

View file

@ -91,11 +91,8 @@ class VoyagerStaffEffect extends OneShotEffect {
if (controller != null && creature != null && sourcePermanent != null) { if (controller != null && creature != null && sourcePermanent != null) {
if (controller.moveCardToExileWithInfo(creature, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { if (controller.moveCardToExileWithInfo(creature, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
//create delayed triggered ability //create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
delayedAbility.setSourceId(source.getSourceId()); new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)), source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }
@ -106,4 +103,4 @@ class VoyagerStaffEffect extends OneShotEffect {
public VoyagerStaffEffect copy() { public VoyagerStaffEffect copy() {
return new VoyagerStaffEffect(this); return new VoyagerStaffEffect(this);
} }
} }

View file

@ -30,7 +30,6 @@ package mage.sets.saviorsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
@ -99,11 +98,7 @@ class FeralLightningEffect extends OneShotEffect {
if (tokenPermanent != null) { if (tokenPermanent != null) {
ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;

View file

@ -128,11 +128,8 @@ class VenserTheSojournerEffect extends OneShotEffect {
if (permanent != null) { if (permanent != null) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
//create delayed triggered ability //create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
delayedAbility.setSourceId(source.getSourceId()); new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD)), source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -90,21 +90,21 @@ public class OracleEnVec extends CardImpl {
} }
class OracleEnVecEffect extends OneShotEffect { class OracleEnVecEffect extends OneShotEffect {
OracleEnVecEffect() { OracleEnVecEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "Target opponent chooses any number of creatures he or she controls. During that player's next turn, the chosen creatures attack if able, and other creatures can't attack. At the beginning of that turn's end step, destroy each of the chosen creatures that didn't attack"; this.staticText = "Target opponent chooses any number of creatures he or she controls. During that player's next turn, the chosen creatures attack if able, and other creatures can't attack. At the beginning of that turn's end step, destroy each of the chosen creatures that didn't attack";
} }
OracleEnVecEffect(final OracleEnVecEffect effect) { OracleEnVecEffect(final OracleEnVecEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public OracleEnVecEffect copy() { public OracleEnVecEffect copy() {
return new OracleEnVecEffect(this); return new OracleEnVecEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
@ -116,18 +116,13 @@ class OracleEnVecEffect extends OneShotEffect {
RequirementEffect effect = new OracleEnVecMustAttackRequirementEffect(); RequirementEffect effect = new OracleEnVecMustAttackRequirementEffect();
effect.setTargetPointer(new FixedTarget(permanent.getId())); effect.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect, source); game.addEffect(effect, source);
} } else {
else {
RestrictionEffect effect = new OracleEnVecCantAttackRestrictionEffect(); RestrictionEffect effect = new OracleEnVecCantAttackRestrictionEffect();
effect.setTargetPointer(new FixedTarget(permanent.getId())); effect.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect, source); game.addEffect(effect, source);
} }
} }
DelayedTriggeredAbility delayedAbility = new OracleEnVecDelayedTriggeredAbility(game.getTurnNum(), target.getTargets()); game.addDelayedTriggeredAbility(new OracleEnVecDelayedTriggeredAbility(game.getTurnNum(), target.getTargets()), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }
@ -164,7 +159,7 @@ class OracleEnVecMustAttackRequirementEffect extends RequirementEffect {
public boolean mustBlock(Game game) { public boolean mustBlock(Game game) {
return false; return false;
} }
@Override @Override
public boolean isInactive(Ability source, Game game) { public boolean isInactive(Ability source, Game game) {
return startingTurn != game.getTurnNum() return startingTurn != game.getTurnNum()
@ -202,7 +197,7 @@ class OracleEnVecCantAttackRestrictionEffect extends RestrictionEffect {
public boolean canAttack(Game game) { public boolean canAttack(Game game) {
return false; return false;
} }
@Override @Override
public boolean isInactive(Ability source, Game game) { public boolean isInactive(Ability source, Game game) {
return startingTurn != game.getTurnNum() return startingTurn != game.getTurnNum()
@ -217,7 +212,7 @@ class OracleEnVecCantAttackRestrictionEffect extends RestrictionEffect {
} }
class OracleEnVecDelayedTriggeredAbility extends DelayedTriggeredAbility { class OracleEnVecDelayedTriggeredAbility extends DelayedTriggeredAbility {
private final int startingTurn; private final int startingTurn;
OracleEnVecDelayedTriggeredAbility(int startingTurn, List<UUID> chosenCreatures) { OracleEnVecDelayedTriggeredAbility(int startingTurn, List<UUID> chosenCreatures) {
@ -252,25 +247,25 @@ class OracleEnVecDelayedTriggeredAbility extends DelayedTriggeredAbility {
} }
class OracleEnVecDestroyEffect extends OneShotEffect { class OracleEnVecDestroyEffect extends OneShotEffect {
private final List<UUID> chosenCreatures; private final List<UUID> chosenCreatures;
OracleEnVecDestroyEffect(List<UUID> chosenCreatures) { OracleEnVecDestroyEffect(List<UUID> chosenCreatures) {
super(Outcome.DestroyPermanent); super(Outcome.DestroyPermanent);
this.chosenCreatures = chosenCreatures; this.chosenCreatures = chosenCreatures;
this.staticText = "destroy each of the chosen creatures that didn't attack"; this.staticText = "destroy each of the chosen creatures that didn't attack";
} }
OracleEnVecDestroyEffect(final OracleEnVecDestroyEffect effect) { OracleEnVecDestroyEffect(final OracleEnVecDestroyEffect effect) {
super(effect); super(effect);
this.chosenCreatures = effect.chosenCreatures; this.chosenCreatures = effect.chosenCreatures;
} }
@Override @Override
public OracleEnVecDestroyEffect copy() { public OracleEnVecDestroyEffect copy() {
return new OracleEnVecDestroyEffect(this); return new OracleEnVecDestroyEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn"); AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");

View file

@ -110,11 +110,7 @@ class GiftOfImmortalityEffect extends OneShotEffect {
//create delayed triggered ability //create delayed triggered ability
Effect effect = new GiftOfImmortalityReturnEnchantmentEffect(); Effect effect = new GiftOfImmortalityReturnEnchantmentEffect();
effect.setTargetPointer(new FixedTarget(permanent, game)); effect.setTargetPointer(new FixedTarget(permanent, game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;

View file

@ -47,7 +47,7 @@ public class ChurningEddy extends CardImpl {
this.expansionSetCode = "TOR"; this.expansionSetCode = "TOR";
// Return target creature and target land to their owners' hands. // Return target creature and target land to their owners' hands.
Effect effect = new ReturnToHandTargetEffect(true, true); Effect effect = new ReturnToHandTargetEffect(true);
effect.setText("Return target creature and target land to their owners' hands"); effect.setText("Return target creature and target land to their owners' hands");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());

View file

@ -55,19 +55,17 @@ import mage.players.Player;
*/ */
public class MemoryJar extends CardImpl { public class MemoryJar extends CardImpl {
public MemoryJar(UUID ownerId) { public MemoryJar(UUID ownerId) {
super(ownerId, 129, "Memory Jar", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{5}"); super(ownerId, 129, "Memory Jar", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{5}");
this.expansionSetCode = "ULG"; this.expansionSetCode = "ULG";
// {tap}, Sacrifice Memory Jar: Each player exiles all cards from his or her hand face down and draws seven cards. // {T}, Sacrifice Memory Jar: Each player exiles all cards from his or her hand face down and draws seven cards.
// At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each // At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each
//card he or she exiled this way. //card he or she exiled this way.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MemoryJarEffect(), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MemoryJarEffect(), new TapSourceCost());
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
public MemoryJar(final MemoryJar card) { public MemoryJar(final MemoryJar card) {
@ -82,30 +80,26 @@ public class MemoryJar extends CardImpl {
class MemoryJarEffect extends OneShotEffect { class MemoryJarEffect extends OneShotEffect {
public MemoryJarEffect() public MemoryJarEffect() {
{
super(Outcome.DrawCard); super(Outcome.DrawCard);
staticText = "Each player exiles all cards from his or her hand face down and draws seven cards. At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way."; staticText = "Each player exiles all cards from his or her hand face down and draws seven cards. At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way.";
} }
public MemoryJarEffect(final MemoryJarEffect effect)
{ public MemoryJarEffect(final MemoryJarEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) public boolean apply(Game game, Ability source) {
{
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
//Exile hand //Exile hand
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) if (player != null) {
{
Cards hand = player.getHand(); Cards hand = player.getHand();
while (hand.size() > 0) { while (hand.size() > 0) {
Card card = hand.get(hand.iterator().next(), game); Card card = hand.get(hand.iterator().next(), game);
if(card != null) if (card != null) {
{
card.moveToExile(getId(), "Memory Jar", source.getSourceId(), game); card.moveToExile(getId(), "Memory Jar", source.getSourceId(), game);
card.setFaceDown(true, game); card.setFaceDown(true, game);
cards.add(card); cards.add(card);
@ -114,22 +108,16 @@ class MemoryJarEffect extends OneShotEffect {
} }
} }
//Draw 7 cards //Draw 7 cards
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) if (player != null) {
{
player.drawCards(7, game); player.drawCards(7, game);
} }
} }
//Delayed ability //Delayed ability
Effect effect = new MemoryJarDelayedEffect(); Effect effect = new MemoryJarDelayedEffect();
effect.setValue("MemoryJarCards", cards); effect.setValue("MemoryJarCards", cards);
DelayedTriggeredAbility delayedAbility = new MemoryJarDelayedTriggeredAbility(effect); game.addDelayedTriggeredAbility(new MemoryJarDelayedTriggeredAbility(effect), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
@ -140,16 +128,16 @@ class MemoryJarEffect extends OneShotEffect {
} }
class MemoryJarDelayedEffect extends OneShotEffect { class MemoryJarDelayedEffect extends OneShotEffect {
public MemoryJarDelayedEffect() public MemoryJarDelayedEffect() {
{
super(Outcome.DrawCard); super(Outcome.DrawCard);
staticText = "At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way."; staticText = "At the beginning of the next end step, each player discards his or her hand and returns to his or her hand each card he or she exiled this way";
} }
public MemoryJarDelayedEffect(final MemoryJarDelayedEffect effect)
{ public MemoryJarDelayedEffect(final MemoryJarDelayedEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public MemoryJarDelayedEffect copy() { public MemoryJarDelayedEffect copy() {
return new MemoryJarDelayedEffect(this); return new MemoryJarDelayedEffect(this);
@ -157,15 +145,13 @@ class MemoryJarDelayedEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Cards cards = (Cards)this.getValue("MemoryJarCards"); Cards cards = (Cards) this.getValue("MemoryJarCards");
if(cards != null) if (cards != null) {
{
//Discard //Discard
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) if (player != null) {
{
player.discard(player.getHand().size(), false, source, game); player.discard(player.getHand().size(), false, source, game);
} }
} }
@ -178,7 +164,7 @@ class MemoryJarDelayedEffect extends OneShotEffect {
} }
return false; return false;
} }
} }
class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility { class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility {
@ -206,6 +192,4 @@ class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility {
return true; return true;
} }
}
}

View file

@ -31,7 +31,6 @@ import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
@ -61,10 +60,10 @@ public class VanishIntoMemory extends CardImpl {
super(ownerId, 31, "Vanish into Memory", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{W}{U}"); super(ownerId, 31, "Vanish into Memory", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{W}{U}");
this.expansionSetCode = "DDI"; this.expansionSetCode = "DDI";
// Exile target creature. You draw cards equal to that creature's power. // Exile target creature. You draw cards equal to that creature's power.
// At the beginning of your next upkeep, return that card to the battlefield under its owner's control. If you do, discard cards equal to that creature's toughness. // At the beginning of your next upkeep, return that card to the battlefield under its owner's control. If you do, discard cards equal to that creature's toughness.
this.getSpellAbility().addEffect(new VanishIntoMemoryEffect()); this.getSpellAbility().addEffect(new VanishIntoMemoryEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
} }
public VanishIntoMemory(final VanishIntoMemory card) { public VanishIntoMemory(final VanishIntoMemory card) {
@ -102,12 +101,8 @@ class VanishIntoMemoryEffect extends OneShotEffect {
Card card = game.getCard(permanent.getId()); Card card = game.getCard(permanent.getId());
if (card != null) { if (card != null) {
//create delayed triggered ability //create delayed triggered ability
DelayedTriggeredAbility delayedAbility game.addDelayedTriggeredAbility(new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(
= new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new VanishIntoMemoryReturnFromExileEffect(new MageObjectReference(card, game))); new VanishIntoMemoryReturnFromExileEffect(new MageObjectReference(card, game))), source);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
} }
} }
return true; return true;
@ -189,7 +184,7 @@ class VanishIntoMemoryEntersBattlefieldEffect extends ReplacementEffectImpl {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
Player you = game.getPlayer(source.getControllerId()); Player you = game.getPlayer(source.getControllerId());
if (you != null) { if (you != null) {
you.discard(permanent.getToughness().getValue(), false, source, game); you.discard(permanent.getToughness().getValue(), false, source, game);
} }
discard(); // use only once discard(); // use only once
@ -201,4 +196,4 @@ class VanishIntoMemoryEntersBattlefieldEffect extends ReplacementEffectImpl {
public VanishIntoMemoryEntersBattlefieldEffect copy() { public VanishIntoMemoryEntersBattlefieldEffect copy() {
return new VanishIntoMemoryEntersBattlefieldEffect(this); return new VanishIntoMemoryEntersBattlefieldEffect(this);
} }
} }

View file

@ -32,7 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.abilities.mana.AnyColorManaAbility; import mage.abilities.mana.AnyColorManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -41,6 +41,7 @@ import mage.constants.Rarity;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -52,7 +53,7 @@ public class UndiscoveredParadise extends CardImpl {
super(ownerId, 167, "Undiscovered Paradise", Rarity.RARE, new CardType[]{CardType.LAND}, ""); super(ownerId, 167, "Undiscovered Paradise", Rarity.RARE, new CardType[]{CardType.LAND}, "");
this.expansionSetCode = "VIS"; this.expansionSetCode = "VIS";
// {tap}: Add one mana of any color to your mana pool. During your next untap step, as you untap your permanents, return Undiscovered Paradise to its owner's hand. // {T}: Add one mana of any color to your mana pool. During your next untap step, as you untap your permanents, return Undiscovered Paradise to its owner's hand.
Ability ability = new AnyColorManaAbility(); Ability ability = new AnyColorManaAbility();
ability.addEffect(new UndiscoveredParadiseEffect()); ability.addEffect(new UndiscoveredParadiseEffect());
this.addAbility(ability); this.addAbility(ability);
@ -83,11 +84,9 @@ class UndiscoveredParadiseEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
AtBeginningOfUntapDelayedTriggeredAbility delayedAbility = new AtBeginningOfUntapDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)); Effect effect = new ReturnToHandTargetEffect();
delayedAbility.setSourceId(source.getSourceId()); effect.setTargetPointer(new FixedTarget(permanent, game));
delayedAbility.setControllerId(source.getControllerId()); game.addDelayedTriggeredAbility(new AtBeginningOfUntapDelayedTriggeredAbility(effect));
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
return false; return false;
@ -112,10 +111,9 @@ class AtBeginningOfUntapDelayedTriggeredAbility extends DelayedTriggeredAbility
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP_STEP_PRE ; return event.getType() == GameEvent.EventType.UNTAP_STEP_PRE;
} }
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (game.getActivePlayerId().equals(controllerId)) { if (game.getActivePlayerId().equals(controllerId)) {

View file

@ -82,9 +82,7 @@ class ChancellorEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
ability.setSourceId(source.getSourceId()); game.addDelayedTriggeredAbility(ability, source);
ability.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(ability);
return true; return true;
} }

View file

@ -29,10 +29,7 @@ public class MistmeadowWitchEffect extends OneShotEffect {
if (permanent.moveToExile(source.getSourceId(), "Mistmeadow Witch Exile", source.getSourceId(), game)) { if (permanent.moveToExile(source.getSourceId(), "Mistmeadow Witch Exile", source.getSourceId(), game)) {
//create delayed triggered ability //create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD)); AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
delayedAbility.setSourceId(source.getSourceId()); game.addDelayedTriggeredAbility(delayedAbility, source);
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -47,26 +47,19 @@ import mage.util.CardUtil;
*/ */
public class ReturnToHandTargetEffect extends OneShotEffect { public class ReturnToHandTargetEffect extends OneShotEffect {
boolean withName;
protected boolean multitargetHandling; protected boolean multitargetHandling;
public ReturnToHandTargetEffect() { public ReturnToHandTargetEffect() {
this(true); this(false);
} }
public ReturnToHandTargetEffect(boolean withName) { public ReturnToHandTargetEffect(boolean multitargetHandling) {
this(withName, false);
}
public ReturnToHandTargetEffect(boolean withName, boolean multitargetHandling) {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.withName = withName;
this.multitargetHandling = multitargetHandling; this.multitargetHandling = multitargetHandling;
} }
public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) { public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) {
super(effect); super(effect);
this.withName = effect.withName;
this.multitargetHandling = effect.multitargetHandling; this.multitargetHandling = effect.multitargetHandling;
} }

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.util; package mage.util;
import java.io.Serializable; import java.io.Serializable;
@ -53,12 +52,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
protected int modCount; protected int modCount;
protected int index; protected int index;
public CircularList() {} public CircularList() {
}
public CircularList(final CircularList<E> cList) { public CircularList(final CircularList<E> cList) {
this.modCount = cList.modCount; this.modCount = cList.modCount;
for (E entry: cList.list) { for (E entry : cList.list) {
this.list.add((E)entry); this.list.add((E) entry);
} }
this.index = cList.index; this.index = cList.index;
} }
@ -68,7 +68,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
/** /**
* Inserts an element into the current position * Inserts an element into the current position
*
* @param e * @param e
* @return * @return
*/ */
@ -84,14 +85,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try { try {
list.add(index, element); list.add(index, element);
modCount++; modCount++;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
/** /**
* *
* @param e the element to set as current * @param e the element to set as current
* @return true if element e exists and index was set * @return true if element e exists and index was set
*/ */
@ -104,7 +104,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
/** /**
* Retrieves the element at the current position * Retrieves the element at the current position
*
* @return * @return
*/ */
public E get() { public E get() {
@ -117,9 +118,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
/** /**
* Returns the next element in the list. Will loop around to the beginning * Returns the next element in the list. Will loop around to the beginning
* of the list if the current element is the last. * of the list if the current element is the last.
* *
* @return the next element in the list * @return the next element in the list
*/ */
public E getNext() { public E getNext() {
@ -127,8 +128,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
/** /**
* Returns the previous element in the list. Will loop around to the end * Returns the previous element in the list. Will loop around to the end of
* of the list if the current element is the first. * the list if the current element is the first.
* *
* @return the previous element in the list * @return the previous element in the list
*/ */
@ -153,8 +154,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
checkPointer(); checkPointer();
modCount++; modCount++;
return ret; return ret;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -167,8 +167,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
checkPointer(); checkPointer();
modCount++; modCount++;
return ret; return ret;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -178,8 +177,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try { try {
index = incrementListPointer(index); index = incrementListPointer(index);
return index; return index;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -197,8 +195,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try { try {
index = decrementListPointer(index); index = decrementListPointer(index);
return index; return index;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -212,14 +209,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
/** /**
* This method should only be called from a locked method * This method should only be called from a locked method thus it is not
* thus it is not necessary to lock from this method * necessary to lock from this method
*/ */
private int checkPointer() { private int checkPointer() {
if (index > list.size()) { if (index > list.size()) {
index = list.size() - 1; index = list.size() - 1;
} } else if (index < 0) {
else if (index < 0) {
index = 0; index = 0;
} }
return index; return index;
@ -270,8 +266,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try { try {
modCount++; modCount++;
return list.addAll(index, c); return list.addAll(index, c);
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -284,8 +279,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
modCount++; modCount++;
checkPointer(); checkPointer();
return ret; return ret;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -298,8 +292,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
modCount++; modCount++;
checkPointer(); checkPointer();
return ret; return ret;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -311,8 +304,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
list.clear(); list.clear();
modCount++; modCount++;
index = 0; index = 0;
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -323,8 +315,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try { try {
modCount++; modCount++;
return list.set(index, element); return list.set(index, element);
} } finally {
finally {
lock.unlock(); lock.unlock();
} }
} }
@ -363,7 +354,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
return new CircularListIterator<>(index); return new CircularListIterator<>(index);
} }
private class CircularIterator<E> implements Iterator<E> { private class CircularIterator<E> implements Iterator<E> {
int cursor; int cursor;
int lastIndex; int lastIndex;
@ -405,7 +396,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
private class CircularListIterator<E> implements ListIterator<E> { private class CircularListIterator<E> implements ListIterator<E> {
int cursor; int cursor;
int lastIndex; int lastIndex;
int firstIndex; int firstIndex;
@ -499,5 +491,4 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
} }
} }

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,16 +20,15 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.watchers; package mage.watchers;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -40,12 +39,13 @@ import mage.game.events.GameEvent;
*/ */
public class Watchers extends HashMap<String, Watcher> { public class Watchers extends HashMap<String, Watcher> {
public Watchers() {} public Watchers() {
}
public Watchers(final Watchers watchers) { public Watchers(final Watchers watchers) {
for (Map.Entry<String, Watcher> entry: watchers.entrySet()) { watchers.entrySet().stream().forEach((entry) -> {
this.put(entry.getKey(), entry.getValue().copy()); this.put(entry.getKey(), entry.getValue().copy());
} });
} }
public Watchers copy() { public Watchers copy() {
@ -59,15 +59,16 @@ public class Watchers extends HashMap<String, Watcher> {
} }
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
for (Watcher watcher: this.values()) { for (Iterator<Watcher> it = this.values().iterator(); it.hasNext();) {
Watcher watcher = it.next();
watcher.watch(event, game); watcher.watch(event, game);
} }
} }
public void reset() { public void reset() {
for (Watcher watcher: this.values()) { this.values().stream().forEach((watcher) -> {
watcher.reset(); watcher.reset();
} });
} }
public Watcher get(String key, UUID id) { public Watcher get(String key, UUID id) {