From 5d94ed8dd03e0646cc160a337aa78bb17b6856f2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 2 Oct 2016 17:27:05 +0200 Subject: [PATCH] Some clean up changes. --- .../java/mage/server/TableController.java | 2 +- .../mage/sets/apocalypse/CoastalDrake.java | 2 +- .../battleforzendikar/ClutchOfCurrents.java | 2 +- .../betrayersofkamigawa/GoryosVengeance.java | 5 +- .../KikiJikiMirrorBreaker.java | 7 +- .../OtherworldlyJourney.java | 7 +- .../commander2014/DarettiScrapSavant.java | 7 +- .../sets/commander2015/SyntheticDestiny.java | 10 +-- .../sets/conflux/BrackwaterElemental.java | 7 +- .../src/mage/sets/darksteel/TearsOfRage.java | 7 +- .../sets/dragonsoftarkir/MirrorMockery.java | 7 +- .../src/mage/sets/eldritchmoon/CropSigil.java | 2 +- .../mage/sets/eldritchmoon/IdentityThief.java | 7 +- .../mage/sets/eldritchmoon/LongRoadHome.java | 14 ++-- .../eldritchmoon/OtherworldlyOutburst.java | 6 +- .../src/mage/sets/eventide/Flickerwisp.java | 27 ++++---- .../sets/futuresight/VenserShaperSavant.java | 2 +- .../src/mage/sets/gatecrash/Voidwalk.java | 8 +-- .../src/mage/sets/iceage/Necropotence.java | 9 +-- .../khansoftarkir/MeanderingTowershell.java | 6 +- .../sets/lorwyn/IncandescentSoulstoke.java | 7 +- .../mage/sets/magic2011/MystifyingMaze.java | 28 ++++---- .../LilianaDefiantNecromancer.java | 7 +- .../mage/sets/mastersedition/RainbowVale.java | 6 +- .../mage/sets/mirrodin/ClockworkBeetle.java | 27 +++++--- .../sets/mirrodinbesieged/VirulentWound.java | 7 +- .../mage/sets/newphyrexia/KarnLiberated.java | 6 +- .../ChandraFlamecaller.java | 15 ++-- .../sets/oathofthegatewatch/SweepAway.java | 4 +- .../src/mage/sets/ravnica/VoyagerStaff.java | 9 +-- .../saviorsofkamigawa/FeralLightning.java | 7 +- .../scarsofmirrodin/VenserTheSojourner.java | 7 +- .../src/mage/sets/tempest/OracleEnVec.java | 33 ++++----- .../mage/sets/theros/GiftOfImmortality.java | 6 +- .../src/mage/sets/torment/ChurningEddy.java | 2 +- .../src/mage/sets/urzaslegacy/MemoryJar.java | 66 +++++++----------- .../sets/venservskoth/VanishIntoMemory.java | 17 ++--- .../sets/visions/UndiscoveredParadise.java | 16 ++--- .../abilities/common/ChancellorAbility.java | 4 +- .../effects/common/MistmeadowWitchEffect.java | 5 +- .../common/ReturnToHandTargetEffect.java | 11 +-- .../src/main/java/mage/util/CircularList.java | 69 ++++++++----------- .../src/main/java/mage/watchers/Watchers.java | 27 ++++---- 43 files changed, 187 insertions(+), 343 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 4d99b36126..5e18b5badc 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -601,7 +601,7 @@ public class TableController { ServerMessagesUtil.getInstance().incGamesStarted(); // 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() + "]"); if (match.getGame() != null) { logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId())); diff --git a/Mage.Sets/src/mage/sets/apocalypse/CoastalDrake.java b/Mage.Sets/src/mage/sets/apocalypse/CoastalDrake.java index 96d4179380..b7db5ad76b 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/CoastalDrake.java +++ b/Mage.Sets/src/mage/sets/apocalypse/CoastalDrake.java @@ -60,7 +60,7 @@ public class CoastalDrake extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // {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.addCost(new TapSourceCost()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/battleforzendikar/ClutchOfCurrents.java b/Mage.Sets/src/mage/sets/battleforzendikar/ClutchOfCurrents.java index a3ee5c81c5..06e51435fe 100644 --- a/Mage.Sets/src/mage/sets/battleforzendikar/ClutchOfCurrents.java +++ b/Mage.Sets/src/mage/sets/battleforzendikar/ClutchOfCurrents.java @@ -46,7 +46,7 @@ public class ClutchOfCurrents extends CardImpl { this.expansionSetCode = "BFZ"; // 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()); // Awaken 3—{4}{U} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java index 4a6030d42e..51fac9de3a 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java @@ -121,10 +121,7 @@ class GoryosVengeanceEffect extends OneShotEffect { Effect exileEffect = new ExileTargetEffect("Exile " + permanent.getName() + " at the beginning of the next end step"); exileEffect.setTargetPointer(new FixedTarget(permanent, game)); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(delayedAbility, source); return true; } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/KikiJikiMirrorBreaker.java b/Mage.Sets/src/mage/sets/championsofkamigawa/KikiJikiMirrorBreaker.java index 8eef2b60f3..6f8b52b95a 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/KikiJikiMirrorBreaker.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/KikiJikiMirrorBreaker.java @@ -30,7 +30,6 @@ package mage.sets.championsofkamigawa; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.costs.common.TapSourceCost; @@ -118,11 +117,7 @@ class KikiJikiMirrorBreakerEffect extends OneShotEffect { for (Permanent addedToken : effect.getAddedPermanent()) { SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId()); sacrificeEffect.setTargetPointer(new FixedTarget(addedToken.getId())); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source); } return true; } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/OtherworldlyJourney.java b/Mage.Sets/src/mage/sets/championsofkamigawa/OtherworldlyJourney.java index 7325f23502..aa9cad60a3 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/OtherworldlyJourney.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/OtherworldlyJourney.java @@ -103,10 +103,7 @@ class OtherworldlyJourneyEffect extends OneShotEffect { //create delayed triggered ability DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OtherworldlyJourneyReturnFromExileEffect(new MageObjectReference(card, game))); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(delayedAbility, source); } } return true; @@ -198,4 +195,4 @@ class OtherworldlyJourneyEntersBattlefieldEffect extends ReplacementEffectImpl { public OtherworldlyJourneyEntersBattlefieldEffect copy() { return new OtherworldlyJourneyEntersBattlefieldEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java b/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java index 9c44c5e675..a06c8a1633 100644 --- a/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java +++ b/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java @@ -29,7 +29,6 @@ package mage.sets.commander2014; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.LoyaltyAbility; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.CanBeYourCommanderAbility; @@ -247,11 +246,7 @@ class DarettiScrapSavantEffect extends OneShotEffect { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); 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"); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/commander2015/SyntheticDestiny.java b/Mage.Sets/src/mage/sets/commander2015/SyntheticDestiny.java index 8dd44316de..ba90702e00 100644 --- a/Mage.Sets/src/mage/sets/commander2015/SyntheticDestiny.java +++ b/Mage.Sets/src/mage/sets/commander2015/SyntheticDestiny.java @@ -33,9 +33,7 @@ import java.util.Set; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; -import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -97,12 +95,8 @@ class SyntheticDestinyEffect extends OneShotEffect { cardsToExile.addAll(game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), controller.getId(), game)); controller.moveCards(cardsToExile, Zone.EXILED, source, game); //Delayed ability - Effect effect = new SyntheticDestinyDelayedEffect(cardsToExile.size()); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new SyntheticDestinyDelayedEffect(cardsToExile.size())), source); return true; } diff --git a/Mage.Sets/src/mage/sets/conflux/BrackwaterElemental.java b/Mage.Sets/src/mage/sets/conflux/BrackwaterElemental.java index d91c96d146..2404d9340d 100644 --- a/Mage.Sets/src/mage/sets/conflux/BrackwaterElemental.java +++ b/Mage.Sets/src/mage/sets/conflux/BrackwaterElemental.java @@ -30,7 +30,6 @@ package mage.sets.conflux; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.AttacksOrBlocksTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -97,11 +96,7 @@ class BrackwaterElementalSacrificeEffect extends OneShotEffect { if (sourcePermanent != null) { SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice {this}"); sacrificeEffect.setTargetPointer(new FixedTarget(sourcePermanent.getId())); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source); } return false; } diff --git a/Mage.Sets/src/mage/sets/darksteel/TearsOfRage.java b/Mage.Sets/src/mage/sets/darksteel/TearsOfRage.java index a5516376d7..e80febd5d0 100644 --- a/Mage.Sets/src/mage/sets/darksteel/TearsOfRage.java +++ b/Mage.Sets/src/mage/sets/darksteel/TearsOfRage.java @@ -29,7 +29,6 @@ package mage.sets.darksteel; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.dynamicvalue.common.AttackingCreatureCount; @@ -100,11 +99,7 @@ class TearsOfRageEffect extends OneShotEffect { if (controller != null) { 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)); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/MirrorMockery.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/MirrorMockery.java index cef7a5da22..82aade8bbd 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/MirrorMockery.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/MirrorMockery.java @@ -29,7 +29,6 @@ package mage.sets.dragonsoftarkir; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.AttacksAttachedTriggeredAbility; import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; import mage.abilities.effects.OneShotEffect; @@ -111,11 +110,7 @@ class MirrorMockeryEffect extends OneShotEffect { if (addedToken != null) { ExileTargetEffect exileEffect = new ExileTargetEffect(); exileEffect.setTargetPointer(new FixedTarget(addedToken, game)); - DelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source); } } return true; diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/CropSigil.java b/Mage.Sets/src/mage/sets/eldritchmoon/CropSigil.java index 66e8358a08..3c19273a4f 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/CropSigil.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/CropSigil.java @@ -68,7 +68,7 @@ public class CropSigil extends CardImpl { // Delirium — {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. - 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(), "Delirium — {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"); diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/IdentityThief.java b/Mage.Sets/src/mage/sets/eldritchmoon/IdentityThief.java index 2a3834b7e4..2d90b79a91 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/IdentityThief.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/IdentityThief.java @@ -147,11 +147,8 @@ class IdentityThiefEffect extends OneShotEffect { // Copy exiled permanent game.addEffect(copyEffect, source); // Create delayed triggered ability - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)), source); return true; } } diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/LongRoadHome.java b/Mage.Sets/src/mage/sets/eldritchmoon/LongRoadHome.java index 03dfdf21e0..04b93f1c0e 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/LongRoadHome.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/LongRoadHome.java @@ -30,7 +30,6 @@ package mage.sets.eldritchmoon; import java.util.UUID; import mage.MageObjectReference; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; @@ -101,12 +100,8 @@ class LongRoadHomeEffect extends OneShotEffect { Card card = game.getCard(permanent.getId()); if (card != null) { //create delayed triggered ability - DelayedTriggeredAbility delayedAbility - = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LongRoadHomeReturnFromExileEffect(new MageObjectReference(card, game))); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new LongRoadHomeReturnFromExileEffect(new MageObjectReference(card, game))), source); } } return true; @@ -152,8 +147,7 @@ class LongRoadHomeReturnFromExileEffect extends OneShotEffect { MeldCard meldCard = (MeldCard) card; game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getTopHalfCard(), game)), source); game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getBottomHalfCard(), game)), source); - } - else { + } else { game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source); } owner.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null); @@ -205,4 +199,4 @@ class LongRoadHomeEntersBattlefieldEffect extends ReplacementEffectImpl { public LongRoadHomeEntersBattlefieldEffect copy() { return new LongRoadHomeEntersBattlefieldEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/OtherworldlyOutburst.java b/Mage.Sets/src/mage/sets/eldritchmoon/OtherworldlyOutburst.java index 00014c8f4e..1247a7f167 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/OtherworldlyOutburst.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/OtherworldlyOutburst.java @@ -90,11 +90,7 @@ class OtherworldlyOutburstEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - DelayedTriggeredAbility delayedAbility = new OtherworldlyOutburstDelayedTriggeredAbility(source.getFirstTarget()); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new OtherworldlyOutburstDelayedTriggeredAbility(source.getFirstTarget()), source); return true; } } diff --git a/Mage.Sets/src/mage/sets/eventide/Flickerwisp.java b/Mage.Sets/src/mage/sets/eventide/Flickerwisp.java index 45d936c5fb..a953882537 100644 --- a/Mage.Sets/src/mage/sets/eventide/Flickerwisp.java +++ b/Mage.Sets/src/mage/sets/eventide/Flickerwisp.java @@ -28,10 +28,6 @@ package mage.sets.eventide; 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.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -40,6 +36,10 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ReturnFromExileEffect; import mage.abilities.keyword.FlyingAbility; 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.predicate.permanent.AnotherPredicate; import mage.game.Game; @@ -53,12 +53,12 @@ import mage.target.TargetPermanent; */ public class Flickerwisp extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent("another target permanent"); - - static{ + private static final FilterPermanent filter = new FilterPermanent("another target permanent"); + + static { filter.add(new AnotherPredicate()); } - + public Flickerwisp(UUID ownerId) { super(ownerId, 6, "Flickerwisp", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); this.expansionSetCode = "EVE"; @@ -69,7 +69,7 @@ public class Flickerwisp extends CardImpl { // Flying 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. Ability ability = new EntersBattlefieldTriggeredAbility(new FlickerwispEffect()); ability.addTarget(new TargetPermanent(filter)); @@ -105,11 +105,8 @@ class FlickerwispEffect extends OneShotEffect { if (controller != null && permanent != null && sourcePermanent != null) { if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { //create delayed triggered ability - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)), source); return true; } } @@ -120,4 +117,4 @@ class FlickerwispEffect extends OneShotEffect { public FlickerwispEffect copy() { return new FlickerwispEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/futuresight/VenserShaperSavant.java b/Mage.Sets/src/mage/sets/futuresight/VenserShaperSavant.java index 22441d1aba..1ed8e000c7 100644 --- a/Mage.Sets/src/mage/sets/futuresight/VenserShaperSavant.java +++ b/Mage.Sets/src/mage/sets/futuresight/VenserShaperSavant.java @@ -58,7 +58,7 @@ public class VenserShaperSavant extends CardImpl { // Flash this.addAbility(FlashAbility.getInstance()); // 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(); ability.addTarget(target); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/gatecrash/Voidwalk.java b/Mage.Sets/src/mage/sets/gatecrash/Voidwalk.java index e0cc153591..af4e4a5a25 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/Voidwalk.java +++ b/Mage.Sets/src/mage/sets/gatecrash/Voidwalk.java @@ -92,12 +92,8 @@ class VoidwalkEffect extends OneShotEffect { if (permanent != null) { int zcc = game.getState().getZoneChangeCounter(permanent.getId()); if (permanent.moveToExile(null, "", source.getSourceId(), game)) { - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility( - new ReturnToBattlefieldUnderOwnerControlSourceEffect(false, zcc + 1)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new ReturnToBattlefieldUnderOwnerControlSourceEffect(false, zcc + 1)), source); } } } diff --git a/Mage.Sets/src/mage/sets/iceage/Necropotence.java b/Mage.Sets/src/mage/sets/iceage/Necropotence.java index c4e3bfbce5..66ed1793ae 100644 --- a/Mage.Sets/src/mage/sets/iceage/Necropotence.java +++ b/Mage.Sets/src/mage/sets/iceage/Necropotence.java @@ -29,7 +29,6 @@ package mage.sets.iceage; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; @@ -143,14 +142,10 @@ class NecropotenceEffect extends OneShotEffect { Card card = controller.getLibrary().removeFromTop(game); if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, false)) { card.setFaceDown(true, game); - Effect returnToHandEffect = new ReturnToHandTargetEffect(false); + Effect returnToHandEffect = new ReturnToHandTargetEffect(); returnToHandEffect.setText("put that face down card into your hand"); returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU), source); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java b/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java index 641efd34e0..71099d532c 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java @@ -116,11 +116,7 @@ class MeanderingTowershellEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (controller != null && sourcePermanent != null) { controller.moveCardToExileWithInfo(sourcePermanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); - DelayedTriggeredAbility delayedAbility = new AtBeginningNextDeclareAttackersStepNextTurnDelayedTriggeredAbility(); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtBeginningNextDeclareAttackersStepNextTurnDelayedTriggeredAbility(), source); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java b/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java index 55ed2327fc..ea2c49f580 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java +++ b/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java @@ -30,7 +30,6 @@ package mage.sets.lorwyn; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; @@ -136,11 +135,7 @@ class IncandescentSoulstokeEffect extends OneShotEffect { game.addEffect(effect, source); SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId()); sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game)); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source); } } } diff --git a/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java b/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java index cf47f9b2bb..7f5674bfbe 100644 --- a/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java +++ b/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,20 +20,14 @@ * 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.sets.magic2011; 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.common.SimpleActivatedAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; @@ -43,6 +37,11 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ReturnFromExileEffect; import mage.abilities.mana.ColorlessManaAbility; 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.predicate.permanent.ControllerPredicate; import mage.game.Game; @@ -98,11 +97,8 @@ class MystifyingMazeEffect extends OneShotEffect { if (permanent != null) { if (permanent.moveToExile(source.getSourceId(), "Mystifying Maze Exile", source.getSourceId(), game)) { //create delayed triggered ability - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, true)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, true)), source); return true; } } diff --git a/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java b/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java index d286db8669..9b1a557072 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java +++ b/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java @@ -29,7 +29,6 @@ package mage.sets.magicorigins; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.LoyaltyAbility; import mage.abilities.common.DiesCreatureTriggeredAbility; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; @@ -159,11 +158,7 @@ class LilianaDefiantNecromancerEmblemEffect extends OneShotEffect { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); 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"); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/mastersedition/RainbowVale.java b/Mage.Sets/src/mage/sets/mastersedition/RainbowVale.java index 4cc3302017..2fc200b5b9 100644 --- a/Mage.Sets/src/mage/sets/mastersedition/RainbowVale.java +++ b/Mage.Sets/src/mage/sets/mastersedition/RainbowVale.java @@ -86,11 +86,7 @@ public class RainbowVale extends CardImpl { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OpponentGainControlEffect()); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OpponentGainControlEffect())); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/mirrodin/ClockworkBeetle.java b/Mage.Sets/src/mage/sets/mirrodin/ClockworkBeetle.java index 60dd36a4d8..5ade4a83e0 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/ClockworkBeetle.java +++ b/Mage.Sets/src/mage/sets/mirrodin/ClockworkBeetle.java @@ -28,22 +28,23 @@ package mage.sets.mirrodin; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksOrBlocksTriggeredAbility; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; 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.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.counters.CounterType; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; /** * @@ -57,7 +58,11 @@ public class ClockworkBeetle extends CardImpl { this.subtype.add("Insect"); this.power = 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")); + + // Whenever Clockwork Beetle attacks or blocks, remove a +1/+1 counter from it at end of combat. this.addAbility(new AttacksOrBlocksTriggeredAbility(new ClockworkBeetleEffect(), false)); } @@ -72,6 +77,7 @@ public class ClockworkBeetle extends CardImpl { } class ClockworkBeetleEffect extends OneShotEffect { + ClockworkBeetleEffect() { super(Outcome.UnboostCreature); staticText = "remove a +1/+1 counter from {this} at end of combat"; @@ -83,12 +89,12 @@ class ClockworkBeetleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent p = game.getPermanent(source.getSourceId()); - if (p != null) { - AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance())); - ability.setSourceId(source.getSourceId()); - ability.setControllerId(source.getControllerId()); - game.addDelayedTriggeredAbility(ability); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + Effect effect = new RemoveCounterTargetEffect(CounterType.P1P1.createInstance()); + effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter())); + game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(effect), source); + return true; } return false; } @@ -99,4 +105,3 @@ class ClockworkBeetleEffect extends OneShotEffect { } } - diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/VirulentWound.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/VirulentWound.java index 7b62cff342..bfea78d213 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/VirulentWound.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/VirulentWound.java @@ -57,7 +57,6 @@ public class VirulentWound extends CardImpl { super(ownerId, 57, "Virulent Wound", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{B}"); this.expansionSetCode = "MBS"; - // Put a -1/-1 counter on target creature. this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.M1M1.createInstance(), Outcome.UnboostCreature)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); @@ -93,11 +92,7 @@ class VirulentWoundEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - DelayedTriggeredAbility delayedAbility = new VirulentWoundDelayedTriggeredAbility(source.getFirstTarget()); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new VirulentWoundDelayedTriggeredAbility(source.getFirstTarget()), source); return true; } } diff --git a/Mage.Sets/src/mage/sets/newphyrexia/KarnLiberated.java b/Mage.Sets/src/mage/sets/newphyrexia/KarnLiberated.java index 490a16eb67..672a55e00c 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/KarnLiberated.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/KarnLiberated.java @@ -158,11 +158,7 @@ class KarnLiberatedEffect extends OneShotEffect { game.getExile().add(exileId, sourceObject.getIdName(), card); } } - DelayedTriggeredAbility delayedAbility = new KarnLiberatedDelayedTriggeredAbility(exileId); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new KarnLiberatedDelayedTriggeredAbility(exileId), source); game.start(null); return true; } diff --git a/Mage.Sets/src/mage/sets/oathofthegatewatch/ChandraFlamecaller.java b/Mage.Sets/src/mage/sets/oathofthegatewatch/ChandraFlamecaller.java index 2742f5deac..9786c1aa63 100644 --- a/Mage.Sets/src/mage/sets/oathofthegatewatch/ChandraFlamecaller.java +++ b/Mage.Sets/src/mage/sets/oathofthegatewatch/ChandraFlamecaller.java @@ -31,7 +31,6 @@ import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; 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}"); this.expansionSetCode = "OGW"; this.subtype.add("Chandra"); - + 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. this.addAbility(new LoyaltyAbility(new ChandraElementalEffect(), 1)); - + // 0: Discard all the cards in your hand, then draw that many cards plus one. this.addAbility(new LoyaltyAbility(new ChandraDrawEffect(), 0)); - + // -X: Chandra, Flamecaller deals X damage to each creature. this.addAbility(new LoyaltyAbility(new DamageAllEffect(ChandraXValue.getDefault(), new FilterCreaturePermanent("creature")))); } @@ -117,11 +116,7 @@ class ChandraElementalEffect extends OneShotEffect { if (tokenPermanent != null) { ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source); } } return true; @@ -172,7 +167,7 @@ class ChandraDrawEffect extends OneShotEffect { for (Card card : cardsInHand) { player.discard(card, source, game); } - player.drawCards(amount+1, game); + player.drawCards(amount + 1, game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/oathofthegatewatch/SweepAway.java b/Mage.Sets/src/mage/sets/oathofthegatewatch/SweepAway.java index a8d7420325..cb4e84bed5 100644 --- a/Mage.Sets/src/mage/sets/oathofthegatewatch/SweepAway.java +++ b/Mage.Sets/src/mage/sets/oathofthegatewatch/SweepAway.java @@ -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)) { new PutOnLibraryTargetEffect(true).apply(game, source); } else { - new ReturnToHandTargetEffect(true).apply(game, source); + new ReturnToHandTargetEffect().apply(game, source); } } else { - new ReturnToHandTargetEffect(true).apply(game, source); + new ReturnToHandTargetEffect().apply(game, source); } return true; } diff --git a/Mage.Sets/src/mage/sets/ravnica/VoyagerStaff.java b/Mage.Sets/src/mage/sets/ravnica/VoyagerStaff.java index fb3eb5ab80..638d05bea4 100644 --- a/Mage.Sets/src/mage/sets/ravnica/VoyagerStaff.java +++ b/Mage.Sets/src/mage/sets/ravnica/VoyagerStaff.java @@ -91,11 +91,8 @@ class VoyagerStaffEffect extends OneShotEffect { if (controller != null && creature != null && sourcePermanent != null) { if (controller.moveCardToExileWithInfo(creature, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { //create delayed triggered ability - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)), source); return true; } } @@ -106,4 +103,4 @@ class VoyagerStaffEffect extends OneShotEffect { public VoyagerStaffEffect copy() { return new VoyagerStaffEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/FeralLightning.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/FeralLightning.java index 4ddc1d3381..f3ad1788df 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/FeralLightning.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/FeralLightning.java @@ -30,7 +30,6 @@ package mage.sets.saviorsofkamigawa; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; @@ -99,11 +98,7 @@ class FeralLightningEffect extends OneShotEffect { if (tokenPermanent != null) { ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source); } } return true; diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java index b3d27b4877..7b0726d26f 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java @@ -128,11 +128,8 @@ class VenserTheSojournerEffect extends OneShotEffect { if (permanent != null) { if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { //create delayed triggered ability - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( + new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD)), source); return true; } } diff --git a/Mage.Sets/src/mage/sets/tempest/OracleEnVec.java b/Mage.Sets/src/mage/sets/tempest/OracleEnVec.java index ce97d63c5c..eb2d9218af 100644 --- a/Mage.Sets/src/mage/sets/tempest/OracleEnVec.java +++ b/Mage.Sets/src/mage/sets/tempest/OracleEnVec.java @@ -90,21 +90,21 @@ public class OracleEnVec extends CardImpl { } class OracleEnVecEffect extends OneShotEffect { - + OracleEnVecEffect() { 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"; } - + OracleEnVecEffect(final OracleEnVecEffect effect) { super(effect); } - + @Override public OracleEnVecEffect copy() { return new OracleEnVecEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); @@ -116,18 +116,13 @@ class OracleEnVecEffect extends OneShotEffect { RequirementEffect effect = new OracleEnVecMustAttackRequirementEffect(); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); - } - else { + } else { RestrictionEffect effect = new OracleEnVecCantAttackRestrictionEffect(); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); } } - DelayedTriggeredAbility delayedAbility = new OracleEnVecDelayedTriggeredAbility(game.getTurnNum(), target.getTargets()); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new OracleEnVecDelayedTriggeredAbility(game.getTurnNum(), target.getTargets()), source); return true; } } @@ -164,7 +159,7 @@ class OracleEnVecMustAttackRequirementEffect extends RequirementEffect { public boolean mustBlock(Game game) { return false; } - + @Override public boolean isInactive(Ability source, Game game) { return startingTurn != game.getTurnNum() @@ -202,7 +197,7 @@ class OracleEnVecCantAttackRestrictionEffect extends RestrictionEffect { public boolean canAttack(Game game) { return false; } - + @Override public boolean isInactive(Ability source, Game game) { return startingTurn != game.getTurnNum() @@ -217,7 +212,7 @@ class OracleEnVecCantAttackRestrictionEffect extends RestrictionEffect { } class OracleEnVecDelayedTriggeredAbility extends DelayedTriggeredAbility { - + private final int startingTurn; OracleEnVecDelayedTriggeredAbility(int startingTurn, List chosenCreatures) { @@ -252,25 +247,25 @@ class OracleEnVecDelayedTriggeredAbility extends DelayedTriggeredAbility { } class OracleEnVecDestroyEffect extends OneShotEffect { - + private final List chosenCreatures; - + OracleEnVecDestroyEffect(List chosenCreatures) { super(Outcome.DestroyPermanent); this.chosenCreatures = chosenCreatures; this.staticText = "destroy each of the chosen creatures that didn't attack"; } - + OracleEnVecDestroyEffect(final OracleEnVecDestroyEffect effect) { super(effect); this.chosenCreatures = effect.chosenCreatures; } - + @Override public OracleEnVecDestroyEffect copy() { return new OracleEnVecDestroyEffect(this); } - + @Override public boolean apply(Game game, Ability source) { AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn"); diff --git a/Mage.Sets/src/mage/sets/theros/GiftOfImmortality.java b/Mage.Sets/src/mage/sets/theros/GiftOfImmortality.java index 0ae5a41c89..be8e6922c0 100644 --- a/Mage.Sets/src/mage/sets/theros/GiftOfImmortality.java +++ b/Mage.Sets/src/mage/sets/theros/GiftOfImmortality.java @@ -110,11 +110,7 @@ class GiftOfImmortalityEffect extends OneShotEffect { //create delayed triggered ability Effect effect = new GiftOfImmortalityReturnEnchantmentEffect(); effect.setTargetPointer(new FixedTarget(permanent, game)); - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source); } } return true; diff --git a/Mage.Sets/src/mage/sets/torment/ChurningEddy.java b/Mage.Sets/src/mage/sets/torment/ChurningEddy.java index 23f5a207c6..d45eb2f95f 100644 --- a/Mage.Sets/src/mage/sets/torment/ChurningEddy.java +++ b/Mage.Sets/src/mage/sets/torment/ChurningEddy.java @@ -47,7 +47,7 @@ public class ChurningEddy extends CardImpl { this.expansionSetCode = "TOR"; // 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"); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java b/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java index 7546dd79e2..7e2d88c65b 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java @@ -55,19 +55,17 @@ import mage.players.Player; */ public class MemoryJar extends CardImpl { - - public MemoryJar(UUID ownerId) { super(ownerId, 129, "Memory Jar", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{5}"); 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 //card he or she exiled this way. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MemoryJarEffect(), new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); - + } public MemoryJar(final MemoryJar card) { @@ -82,30 +80,26 @@ public class MemoryJar extends CardImpl { class MemoryJarEffect extends OneShotEffect { - public MemoryJarEffect() - { + public MemoryJarEffect() { 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."; } - public MemoryJarEffect(final MemoryJarEffect effect) - { + + public MemoryJarEffect(final MemoryJarEffect effect) { super(effect); } @Override - public boolean apply(Game game, Ability source) - { + public boolean apply(Game game, Ability source) { Cards cards = new CardsImpl(); //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); - if (player != null) - { + if (player != null) { Cards hand = player.getHand(); while (hand.size() > 0) { Card card = hand.get(hand.iterator().next(), game); - if(card != null) - { + if (card != null) { card.moveToExile(getId(), "Memory Jar", source.getSourceId(), game); card.setFaceDown(true, game); cards.add(card); @@ -114,22 +108,16 @@ class MemoryJarEffect extends OneShotEffect { } } //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); - if (player != null) - { + if (player != null) { player.drawCards(7, game); } } //Delayed ability Effect effect = new MemoryJarDelayedEffect(); effect.setValue("MemoryJarCards", cards); - DelayedTriggeredAbility delayedAbility = new MemoryJarDelayedTriggeredAbility(effect); - - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new MemoryJarDelayedTriggeredAbility(effect), source); return true; } @@ -140,16 +128,16 @@ class MemoryJarEffect extends OneShotEffect { } class MemoryJarDelayedEffect extends OneShotEffect { - - public MemoryJarDelayedEffect() - { + + public MemoryJarDelayedEffect() { 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); } + @Override public MemoryJarDelayedEffect copy() { return new MemoryJarDelayedEffect(this); @@ -157,15 +145,13 @@ class MemoryJarDelayedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Cards cards = (Cards)this.getValue("MemoryJarCards"); - - if(cards != null) - { + Cards cards = (Cards) this.getValue("MemoryJarCards"); + + if (cards != null) { //Discard - for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); - if (player != null) - { + if (player != null) { player.discard(player.getHand().size(), false, source, game); } } @@ -178,7 +164,7 @@ class MemoryJarDelayedEffect extends OneShotEffect { } return false; } - + } class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility { @@ -206,6 +192,4 @@ class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility { return true; } - - -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/venservskoth/VanishIntoMemory.java b/Mage.Sets/src/mage/sets/venservskoth/VanishIntoMemory.java index 7722b12194..fe3a7370fc 100644 --- a/Mage.Sets/src/mage/sets/venservskoth/VanishIntoMemory.java +++ b/Mage.Sets/src/mage/sets/venservskoth/VanishIntoMemory.java @@ -31,7 +31,6 @@ import java.util.UUID; import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility; import mage.abilities.effects.OneShotEffect; 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}"); 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. this.getSpellAbility().addEffect(new VanishIntoMemoryEffect()); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } public VanishIntoMemory(final VanishIntoMemory card) { @@ -102,12 +101,8 @@ class VanishIntoMemoryEffect extends OneShotEffect { Card card = game.getCard(permanent.getId()); if (card != null) { //create delayed triggered ability - DelayedTriggeredAbility delayedAbility - = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new VanishIntoMemoryReturnFromExileEffect(new MageObjectReference(card, game))); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility( + new VanishIntoMemoryReturnFromExileEffect(new MageObjectReference(card, game))), source); } } return true; @@ -189,7 +184,7 @@ class VanishIntoMemoryEntersBattlefieldEffect extends ReplacementEffectImpl { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); if (permanent != null) { Player you = game.getPlayer(source.getControllerId()); - if (you != null) { + if (you != null) { you.discard(permanent.getToughness().getValue(), false, source, game); } discard(); // use only once @@ -201,4 +196,4 @@ class VanishIntoMemoryEntersBattlefieldEffect extends ReplacementEffectImpl { public VanishIntoMemoryEntersBattlefieldEffect copy() { return new VanishIntoMemoryEntersBattlefieldEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/visions/UndiscoveredParadise.java b/Mage.Sets/src/mage/sets/visions/UndiscoveredParadise.java index 22ba01cd32..b7bb7b00b3 100644 --- a/Mage.Sets/src/mage/sets/visions/UndiscoveredParadise.java +++ b/Mage.Sets/src/mage/sets/visions/UndiscoveredParadise.java @@ -32,7 +32,7 @@ import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.ReturnToHandSourceEffect; +import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.mana.AnyColorManaAbility; import mage.cards.CardImpl; import mage.constants.CardType; @@ -41,6 +41,7 @@ import mage.constants.Rarity; import mage.game.Game; import mage.game.events.GameEvent; 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}, ""); 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.addEffect(new UndiscoveredParadiseEffect()); this.addAbility(ability); @@ -83,11 +84,9 @@ class UndiscoveredParadiseEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - AtBeginningOfUntapDelayedTriggeredAbility delayedAbility = new AtBeginningOfUntapDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + Effect effect = new ReturnToHandTargetEffect(); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addDelayedTriggeredAbility(new AtBeginningOfUntapDelayedTriggeredAbility(effect)); return true; } return false; @@ -112,10 +111,9 @@ class AtBeginningOfUntapDelayedTriggeredAbility extends DelayedTriggeredAbility @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.UNTAP_STEP_PRE ; + return event.getType() == GameEvent.EventType.UNTAP_STEP_PRE; } - @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getActivePlayerId().equals(controllerId)) { diff --git a/Mage/src/main/java/mage/abilities/common/ChancellorAbility.java b/Mage/src/main/java/mage/abilities/common/ChancellorAbility.java index c782eefc5b..b96049495d 100644 --- a/Mage/src/main/java/mage/abilities/common/ChancellorAbility.java +++ b/Mage/src/main/java/mage/abilities/common/ChancellorAbility.java @@ -82,9 +82,7 @@ class ChancellorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - ability.setSourceId(source.getSourceId()); - ability.setControllerId(source.getControllerId()); - game.addDelayedTriggeredAbility(ability); + game.addDelayedTriggeredAbility(ability, source); return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/MistmeadowWitchEffect.java b/Mage/src/main/java/mage/abilities/effects/common/MistmeadowWitchEffect.java index c67f16ee3b..99825a1e5b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/MistmeadowWitchEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/MistmeadowWitchEffect.java @@ -29,10 +29,7 @@ public class MistmeadowWitchEffect extends OneShotEffect { if (permanent.moveToExile(source.getSourceId(), "Mistmeadow Witch Exile", source.getSourceId(), game)) { //create delayed triggered ability AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD)); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + game.addDelayedTriggeredAbility(delayedAbility, source); return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java index 7733ab8511..5e85cdfac7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java @@ -47,26 +47,19 @@ import mage.util.CardUtil; */ public class ReturnToHandTargetEffect extends OneShotEffect { - boolean withName; protected boolean multitargetHandling; public ReturnToHandTargetEffect() { - this(true); + this(false); } - public ReturnToHandTargetEffect(boolean withName) { - this(withName, false); - } - - public ReturnToHandTargetEffect(boolean withName, boolean multitargetHandling) { + public ReturnToHandTargetEffect(boolean multitargetHandling) { super(Outcome.ReturnToHand); - this.withName = withName; this.multitargetHandling = multitargetHandling; } public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) { super(effect); - this.withName = effect.withName; this.multitargetHandling = effect.multitargetHandling; } diff --git a/Mage/src/main/java/mage/util/CircularList.java b/Mage/src/main/java/mage/util/CircularList.java index 3b0c66234f..27eaf144bf 100644 --- a/Mage/src/main/java/mage/util/CircularList.java +++ b/Mage/src/main/java/mage/util/CircularList.java @@ -24,8 +24,7 @@ * 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.util; import java.io.Serializable; @@ -53,12 +52,13 @@ public class CircularList implements List, Iterable, Serializable { protected int modCount; protected int index; - public CircularList() {} + public CircularList() { + } public CircularList(final CircularList cList) { this.modCount = cList.modCount; - for (E entry: cList.list) { - this.list.add((E)entry); + for (E entry : cList.list) { + this.list.add((E) entry); } this.index = cList.index; } @@ -68,7 +68,8 @@ public class CircularList implements List, Iterable, Serializable { } /** - * Inserts an element into the current position + * Inserts an element into the current position + * * @param e * @return */ @@ -84,14 +85,13 @@ public class CircularList implements List, Iterable, Serializable { try { list.add(index, element); modCount++; - } - finally { + } finally { lock.unlock(); } } /** - * + * * @param e the element to set as current * @return true if element e exists and index was set */ @@ -104,7 +104,8 @@ public class CircularList implements List, Iterable, Serializable { } /** - * Retrieves the element at the current position + * Retrieves the element at the current position + * * @return */ public E get() { @@ -117,9 +118,9 @@ public class CircularList implements List, Iterable, 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. - * + * * @return the next element in the list */ public E getNext() { @@ -127,8 +128,8 @@ public class CircularList implements List, Iterable, Serializable { } /** - * Returns the previous element in the list. Will loop around to the end - * of the list if the current element is the first. + * Returns the previous element in the list. Will loop around to the end of + * the list if the current element is the first. * * @return the previous element in the list */ @@ -153,8 +154,7 @@ public class CircularList implements List, Iterable, Serializable { checkPointer(); modCount++; return ret; - } - finally { + } finally { lock.unlock(); } } @@ -167,8 +167,7 @@ public class CircularList implements List, Iterable, Serializable { checkPointer(); modCount++; return ret; - } - finally { + } finally { lock.unlock(); } } @@ -178,8 +177,7 @@ public class CircularList implements List, Iterable, Serializable { try { index = incrementListPointer(index); return index; - } - finally { + } finally { lock.unlock(); } } @@ -197,8 +195,7 @@ public class CircularList implements List, Iterable, Serializable { try { index = decrementListPointer(index); return index; - } - finally { + } finally { lock.unlock(); } } @@ -212,14 +209,13 @@ public class CircularList implements List, Iterable, Serializable { } /** - * This method should only be called from a locked method - * thus it is not necessary to lock from this method + * This method should only be called from a locked method thus it is not + * necessary to lock from this method */ private int checkPointer() { if (index > list.size()) { index = list.size() - 1; - } - else if (index < 0) { + } else if (index < 0) { index = 0; } return index; @@ -270,8 +266,7 @@ public class CircularList implements List, Iterable, Serializable { try { modCount++; return list.addAll(index, c); - } - finally { + } finally { lock.unlock(); } } @@ -284,8 +279,7 @@ public class CircularList implements List, Iterable, Serializable { modCount++; checkPointer(); return ret; - } - finally { + } finally { lock.unlock(); } } @@ -298,8 +292,7 @@ public class CircularList implements List, Iterable, Serializable { modCount++; checkPointer(); return ret; - } - finally { + } finally { lock.unlock(); } } @@ -311,8 +304,7 @@ public class CircularList implements List, Iterable, Serializable { list.clear(); modCount++; index = 0; - } - finally { + } finally { lock.unlock(); } } @@ -323,8 +315,7 @@ public class CircularList implements List, Iterable, Serializable { try { modCount++; return list.set(index, element); - } - finally { + } finally { lock.unlock(); } } @@ -363,7 +354,7 @@ public class CircularList implements List, Iterable, Serializable { return new CircularListIterator<>(index); } - private class CircularIterator implements Iterator { + private class CircularIterator implements Iterator { int cursor; int lastIndex; @@ -405,7 +396,8 @@ public class CircularList implements List, Iterable, Serializable { } - private class CircularListIterator implements ListIterator { + private class CircularListIterator implements ListIterator { + int cursor; int lastIndex; int firstIndex; @@ -499,5 +491,4 @@ public class CircularList implements List, Iterable, Serializable { } - } diff --git a/Mage/src/main/java/mage/watchers/Watchers.java b/Mage/src/main/java/mage/watchers/Watchers.java index 9955e5ce77..e0dbe5e03a 100644 --- a/Mage/src/main/java/mage/watchers/Watchers.java +++ b/Mage/src/main/java/mage/watchers/Watchers.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,16 +20,15 @@ * 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.watchers; import java.util.HashMap; -import java.util.Map; +import java.util.Iterator; import java.util.UUID; import mage.game.Game; import mage.game.events.GameEvent; @@ -40,12 +39,13 @@ import mage.game.events.GameEvent; */ public class Watchers extends HashMap { - public Watchers() {} + public Watchers() { + } public Watchers(final Watchers watchers) { - for (Map.Entry entry: watchers.entrySet()) { + watchers.entrySet().stream().forEach((entry) -> { this.put(entry.getKey(), entry.getValue().copy()); - } + }); } public Watchers copy() { @@ -59,15 +59,16 @@ public class Watchers extends HashMap { } public void watch(GameEvent event, Game game) { - for (Watcher watcher: this.values()) { + for (Iterator it = this.values().iterator(); it.hasNext();) { + Watcher watcher = it.next(); watcher.watch(event, game); } } public void reset() { - for (Watcher watcher: this.values()) { + this.values().stream().forEach((watcher) -> { watcher.reset(); - } + }); } public Watcher get(String key, UUID id) {