diff --git a/Mage/src/mage/abilities/effects/Effect.java b/Mage/src/mage/abilities/effects/Effect.java index 9dd2aeb82d8..9e09b0f7ebd 100644 --- a/Mage/src/mage/abilities/effects/Effect.java +++ b/Mage/src/mage/abilities/effects/Effect.java @@ -46,6 +46,7 @@ public interface Effect> extends Serializable { UUID getId(); void newId(); String getText(Mode mode); + void setText(String staticText); boolean apply(Game game, Ability source); Outcome getOutcome(); EffectType getEffectType(); diff --git a/Mage/src/mage/abilities/effects/EffectImpl.java b/Mage/src/mage/abilities/effects/EffectImpl.java index c71cc3ef9b6..e1794faec16 100644 --- a/Mage/src/mage/abilities/effects/EffectImpl.java +++ b/Mage/src/mage/abilities/effects/EffectImpl.java @@ -82,6 +82,11 @@ public abstract class EffectImpl> implements Effect { return staticText; } + @Override + public void setText(String staticText) { + this.staticText = staticText; + } + @Override public Outcome getOutcome() { return outcome; diff --git a/Mage/src/mage/abilities/effects/common/ExileAllEffect.java b/Mage/src/mage/abilities/effects/common/ExileAllEffect.java new file mode 100644 index 00000000000..bed64374c23 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/ExileAllEffect.java @@ -0,0 +1,87 @@ +/* + * 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 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.abilities.effects.common; + +import java.util.List; +import java.util.UUID; +import mage.Constants.Outcome; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class ExileAllEffect extends OneShotEffect { + + private FilterPermanent filter; + private String exileZone = null; + private UUID exileId = null; + + public ExileAllEffect(FilterPermanent filter) { + this(filter, null, null); + } + public ExileAllEffect(FilterPermanent filter, UUID exileId, String exileZone) { + super(Outcome.Exile); + this.filter = filter; + this.exileZone = exileZone; + this.exileId = exileId; + setText(); + } + + public ExileAllEffect(final ExileAllEffect effect) { + super(effect); + this.filter = effect.filter.copy(); + this.exileZone = effect.exileZone; + this.exileId = effect.exileId; + } + + @Override + public ExileAllEffect copy() { + return new ExileAllEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getId(), game); + for (Permanent permanent: permanents) { + permanent.moveToExile(exileId, exileZone, source.getSourceId(), game); + } + return true; + } + + private void setText() { + StringBuilder sb = new StringBuilder(); + sb.append("Exile all ").append(filter.getMessage()); + staticText = sb.toString(); + } +} diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java index 609cd049a45..064e043fc90 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java @@ -108,6 +108,9 @@ public class BoostTargetEffect extends ContinuousEffectImpl { @Override public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } StringBuilder sb = new StringBuilder(); Target target = mode.getTargets().get(0); if(target.getNumberOfTargets() > 1){ diff --git a/Mage/src/mage/target/targetpointer/SecondTargetPointer.java b/Mage/src/mage/target/targetpointer/SecondTargetPointer.java new file mode 100644 index 00000000000..680e324c1d5 --- /dev/null +++ b/Mage/src/mage/target/targetpointer/SecondTargetPointer.java @@ -0,0 +1,75 @@ +package mage.target.targetpointer; + +import java.util.*; +import mage.abilities.Ability; +import mage.cards.Card; +import mage.game.Game; + + +public class SecondTargetPointer implements TargetPointer { + + private Map zoneChangeCounter = new HashMap(); + + public static SecondTargetPointer getInstance() { + return new SecondTargetPointer(); + } + + public SecondTargetPointer() { + } + + public SecondTargetPointer(SecondTargetPointer firstTargetPointer) { + this.zoneChangeCounter = new HashMap(); + for (Map.Entry entry : firstTargetPointer.zoneChangeCounter.entrySet()) { + this.zoneChangeCounter.put(entry.getKey(), entry.getValue()); + } + } + + @Override + public void init(Game game, Ability source) { + if (source.getTargets().size() > 1) { + for (UUID target : source.getTargets().get(1).getTargets()) { + Card card = game.getCard(target); + if (card != null) { + this.zoneChangeCounter.put(target, card.getZoneChangeCounter()); + } + } + } + } + + @Override + public List getTargets(Game game, Ability source) { + ArrayList target = new ArrayList(); + if (source.getTargets().size() > 1) { + for (UUID targetId : source.getTargets().get(1).getTargets()) { + Card card = game.getCard(targetId); + if (card != null && zoneChangeCounter.containsKey(targetId) + && card.getZoneChangeCounter() != zoneChangeCounter.get(targetId)) { + continue; + } + target.add(targetId); + } + } + return target; + } + + @Override + public UUID getFirst(Game game, Ability source) { + if (source.getTargets().size() > 1) { + UUID targetId = source.getTargets().get(1).getFirstTarget(); + if (zoneChangeCounter.containsKey(targetId)) { + Card card = game.getCard(targetId); + if (card != null && zoneChangeCounter.containsKey(targetId) + && card.getZoneChangeCounter() != zoneChangeCounter.get(targetId)) { + return null; + } + } + return targetId; + } + return null; + } + + @Override + public TargetPointer copy() { + return new SecondTargetPointer(this); + } +}