diff --git a/Mage/src/mage/abilities/common/delayed/AtEndOfTurnDelayedTriggeredAbility.java b/Mage/src/mage/abilities/common/delayed/AtEndOfTurnDelayedTriggeredAbility.java index cc6792c39b..ba6ad16056 100644 --- a/Mage/src/mage/abilities/common/delayed/AtEndOfTurnDelayedTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/delayed/AtEndOfTurnDelayedTriggeredAbility.java @@ -27,11 +27,13 @@ */ package mage.abilities.common.delayed; +import mage.Constants.TargetController; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.effects.Effect; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; /** * @@ -39,18 +41,46 @@ import mage.game.events.GameEvent.EventType; */ public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility { + private TargetController targetController; + public AtEndOfTurnDelayedTriggeredAbility(Effect effect) { + this(effect, TargetController.ANY); + } + + public AtEndOfTurnDelayedTriggeredAbility(Effect effect, TargetController targetController) { super(effect); + this.targetController = targetController; } public AtEndOfTurnDelayedTriggeredAbility(AtEndOfTurnDelayedTriggeredAbility ability) { super(ability); + this.targetController = ability.targetController; } @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == EventType.END_TURN_STEP_PRE) { - return true; + switch (targetController) { + case ANY: + return true; + case YOU: + boolean yours = event.getPlayerId().equals(this.controllerId); + return yours; + case OPPONENT: + if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { + return true; + } + break; + + case CONTROLLER_ATTACHED_TO: + Permanent attachment = game.getPermanent(sourceId); + if (attachment != null && attachment.getAttachedTo() != null) { + Permanent attachedTo = game.getPermanent(attachment.getAttachedTo()); + if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) { + return true; + } + } + } } return false; } @@ -62,6 +92,22 @@ public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility< @Override public String getRule() { - return "At the beginning of the next end step, " + modes.getText(); + StringBuilder sb = new StringBuilder(); + switch (targetController) { + case YOU: + sb.append("At the beginning of your next end step, "); + break; + case OPPONENT: + sb.append("At the beginning of an opponent's next end step, "); + break; + case ANY: + sb.append("At the beginning of the next end step, "); + break; + case CONTROLLER_ATTACHED_TO: + sb.append("At the beginning of the next end step of enchanted creature's controller, "); + break; + } + sb.append(getEffects().getText(modes.getMode())); + return sb.toString(); } } diff --git a/Mage/src/mage/abilities/effects/common/ExileTargetEffect.java b/Mage/src/mage/abilities/effects/common/ExileTargetEffect.java index 662c294348..c20c148bb6 100644 --- a/Mage/src/mage/abilities/effects/common/ExileTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/ExileTargetEffect.java @@ -28,6 +28,7 @@ package mage.abilities.effects.common; +import java.util.UUID; import mage.Constants.Outcome; import mage.abilities.Ability; import mage.abilities.Mode; @@ -36,8 +37,6 @@ import mage.cards.Card; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * * @author BetaSteward_at_googlemail.com @@ -53,9 +52,9 @@ public class ExileTargetEffect extends OneShotEffect { this.exileId = exileId; } - public ExileTargetEffect(String exileZone) { + public ExileTargetEffect(String effectText) { this(); - this.exileZone = exileZone; + this.staticText = effectText; } public ExileTargetEffect() { @@ -76,11 +75,6 @@ public class ExileTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); - -// if (exileId == null) { -// exileId = getId(); -// } - if (permanent != null) { return permanent.moveToExile(exileId, exileZone, source.getSourceId(), game); } else { @@ -94,6 +88,9 @@ public class ExileTargetEffect extends OneShotEffect { @Override public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } if (mode.getTargets().isEmpty()) { return "Exile it"; } else { diff --git a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInHandEffect.java b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInHandEffect.java index e363bb1876..36538648a8 100644 --- a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInHandEffect.java +++ b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInHandEffect.java @@ -49,6 +49,7 @@ public class SearchLibraryPutInHandEffect extends SearchEffect 0) { Cards cards = new CardsImpl(); @@ -104,14 +113,15 @@ public class SearchLibraryPutInHandEffect extends SearchEffect 0) { sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" "); sb.append(target.getTargetName()).append(revealCards ? ", reveal them, " : "").append(" and put them into your hand"); @@ -119,11 +129,12 @@ public class SearchLibraryPutInHandEffect extends SearchEffect