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();
// 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()));

View file

@ -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);

View file

@ -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}

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");
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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

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.
// 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(),
"<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");

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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;
@ -55,7 +55,7 @@ public class Flickerwisp extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("another target permanent");
static{
static {
filter.add(new AnotherPredicate());
}
@ -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;
}
}

View file

@ -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);

View file

@ -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);
}
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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);
}
}
}

View file

@ -25,15 +25,9 @@
* 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;
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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 {
}
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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;
@ -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;

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)) {
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;
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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());

View file

@ -55,13 +55,11 @@ 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());
@ -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;
}
@ -141,15 +129,15 @@ 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");
Cards cards = (Cards) this.getValue("MemoryJarCards");
if(cards != null)
{
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);
}
}
@ -206,6 +192,4 @@ class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility {
return true;
}
}

View file

@ -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;
@ -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;

View file

@ -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)) {

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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<E> implements List<E>, Iterable<E>, Serializable {
protected int modCount;
protected int index;
public CircularList() {}
public CircularList() {
}
public CircularList(final CircularList<E> 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;
}
@ -69,6 +69,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
/**
* Inserts an element into the current position
*
* @param e
* @return
*/
@ -84,8 +85,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try {
list.add(index, element);
modCount++;
}
finally {
} finally {
lock.unlock();
}
}
@ -105,6 +105,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
/**
* Retrieves the element at the current position
*
* @return
*/
public E get() {
@ -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
* 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<E> implements List<E>, Iterable<E>, Serializable {
checkPointer();
modCount++;
return ret;
}
finally {
} finally {
lock.unlock();
}
}
@ -167,8 +167,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
checkPointer();
modCount++;
return ret;
}
finally {
} finally {
lock.unlock();
}
}
@ -178,8 +177,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try {
index = incrementListPointer(index);
return index;
}
finally {
} finally {
lock.unlock();
}
}
@ -197,8 +195,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try {
index = decrementListPointer(index);
return index;
}
finally {
} finally {
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
* 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<E> implements List<E>, Iterable<E>, Serializable {
try {
modCount++;
return list.addAll(index, c);
}
finally {
} finally {
lock.unlock();
}
}
@ -284,8 +279,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
modCount++;
checkPointer();
return ret;
}
finally {
} finally {
lock.unlock();
}
}
@ -298,8 +292,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
modCount++;
checkPointer();
return ret;
}
finally {
} finally {
lock.unlock();
}
}
@ -311,8 +304,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
list.clear();
modCount++;
index = 0;
}
finally {
} finally {
lock.unlock();
}
}
@ -323,8 +315,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
try {
modCount++;
return list.set(index, element);
}
finally {
} finally {
lock.unlock();
}
}
@ -406,6 +397,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
}
private class CircularListIterator<E> implements ListIterator<E> {
int cursor;
int lastIndex;
int firstIndex;
@ -499,5 +491,4 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
}
}

View file

@ -25,11 +25,10 @@
* 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<String, Watcher> {
public Watchers() {}
public 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());
}
});
}
public Watchers copy() {
@ -59,15 +59,16 @@ public class Watchers extends HashMap<String, Watcher> {
}
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);
}
}
public void reset() {
for (Watcher watcher: this.values()) {
this.values().stream().forEach((watcher) -> {
watcher.reset();
}
});
}
public Watcher get(String key, UUID id) {