Merge origin/master

This commit is contained in:
fireshoes 2015-08-13 10:28:29 -05:00
commit ac8f70f4c3
96 changed files with 3478 additions and 266 deletions

View file

@ -27,39 +27,43 @@
*/
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterStackObject;
import mage.constants.TargetController;
import mage.filter.FilterObject;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.game.stack.StackAbility;
/**
*
* @author LevelX2
*/
public class CantBeTargetedAttachedEffect extends ContinuousRuleModifyingEffectImpl {
private final FilterStackObject filterSource;
private final FilterObject filterSource;
private final AttachmentType attachmentType;
public CantBeTargetedAttachedEffect(FilterStackObject filterSource, Duration duration, AttachmentType attachmentType) {
private final TargetController targetController;
public CantBeTargetedAttachedEffect(FilterObject filterSource, Duration duration, AttachmentType attachmentType, TargetController targetController) {
super(duration, Outcome.Benefit);
this.filterSource = filterSource;
this.attachmentType = attachmentType;
this.targetController = targetController;
}
public CantBeTargetedAttachedEffect(final CantBeTargetedAttachedEffect effect) {
super(effect);
this.filterSource = effect.filterSource.copy();
this.attachmentType = effect.attachmentType;
this.targetController = effect.targetController;
}
@Override
@ -81,8 +85,18 @@ public class CantBeTargetedAttachedEffect extends ContinuousRuleModifyingEffectI
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent attachment = game.getPermanent(source.getSourceId());
if (attachment != null && event.getTargetId().equals(attachment.getAttachedTo())) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
if (targetController.equals(TargetController.OPPONENT)
&& !game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
return false;
}
MageObject mageObject = game.getObject(event.getSourceId());
MageObject sourceObject;
if (mageObject instanceof StackAbility) {
sourceObject = ((StackAbility) mageObject).getSourceObject(game);
} else {
sourceObject = mageObject;
}
if (mageObject != null && filterSource.match(sourceObject, game)) {
return true;
}
}
@ -103,13 +117,13 @@ public class CantBeTargetedAttachedEffect extends ContinuousRuleModifyingEffectI
sb.append(" can't be the target of ");
sb.append(filterSource.getMessage());
if (!duration.toString().isEmpty()) {
sb.append(" ");
sb.append(" ");
if (duration.equals(Duration.EndOfTurn)) {
sb.append("this turn");
} else {
sb.append(duration.toString());
}
}
}
return sb.toString();
}

View file

@ -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,22 +20,23 @@
* 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 mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterStackObject;
import mage.filter.FilterObject;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
/**
@ -44,9 +45,9 @@ import mage.game.stack.StackObject;
*/
public class CantBeTargetedSourceEffect extends ContinuousRuleModifyingEffectImpl {
private final FilterStackObject filterSource;
private final FilterObject filterSource;
public CantBeTargetedSourceEffect(FilterStackObject filterSource, Duration duration) {
public CantBeTargetedSourceEffect(FilterObject filterSource, Duration duration) {
super(duration, Outcome.Benefit);
this.filterSource = filterSource;
setText();
@ -66,7 +67,7 @@ public class CantBeTargetedSourceEffect extends ContinuousRuleModifyingEffectImp
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
@ -75,8 +76,14 @@ public class CantBeTargetedSourceEffect extends ContinuousRuleModifyingEffectImp
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
MageObject sourceObject;
if (stackObject instanceof StackAbility) {
sourceObject = ((StackAbility) stackObject).getSourceObject(game);
} else {
sourceObject = stackObject;
}
if (sourceObject != null && filterSource.match(sourceObject, game)) {
return true;
}
}

View file

@ -27,34 +27,43 @@
*/
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterStackObject;
import mage.constants.TargetController;
import mage.filter.FilterObject;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
/**
*
* @author LevelX2
*/
public class CantBeTargetedTargetEffect extends ContinuousRuleModifyingEffectImpl {
private final FilterStackObject filterSource;
private final FilterObject filterSource;
private final TargetController targetController;
public CantBeTargetedTargetEffect(FilterStackObject filterSource, Duration duration) {
public CantBeTargetedTargetEffect(FilterObject filterSource, Duration duration) {
this(filterSource, duration, TargetController.ANY);
}
public CantBeTargetedTargetEffect(FilterObject filterSource, Duration duration, TargetController targetController) {
super(duration, Outcome.Benefit, false, false);
this.targetController = targetController;
this.filterSource = filterSource;
}
public CantBeTargetedTargetEffect(final CantBeTargetedTargetEffect effect) {
super(effect);
this.filterSource = effect.filterSource.copy();
this.targetController = effect.targetController;
}
@Override
@ -75,8 +84,18 @@ public class CantBeTargetedTargetEffect extends ContinuousRuleModifyingEffectImp
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (getTargetPointer().getTargets(game, source).contains(event.getTargetId())) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
if (targetController.equals(TargetController.OPPONENT)
&& !game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
return false;
}
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
MageObject sourceObject;
if (stackObject instanceof StackAbility) {
sourceObject = ((StackAbility) stackObject).getSourceObject(game);
} else {
sourceObject = stackObject;
}
if (sourceObject != null && filterSource.match(sourceObject, game)) {
return true;
}
}
@ -95,13 +114,13 @@ public class CantBeTargetedTargetEffect extends ContinuousRuleModifyingEffectImp
sb.append(" can't be the target of ");
sb.append(filterSource.getMessage());
if (!duration.toString().isEmpty()) {
sb.append(" ");
sb.append(" ");
if (duration.equals(Duration.EndOfTurn)) {
sb.append("this turn");
} else {
sb.append(duration.toString());
}
}
}
return sb.toString();
}

View file

@ -18,19 +18,26 @@ import mage.target.common.TargetCardInHand;
public class PutPermanentOnBattlefieldEffect extends OneShotEffect {
private final FilterCard filter;
private final boolean useTargetController;
public PutPermanentOnBattlefieldEffect() {
this(new FilterPermanentCard("a permanent card"));
this(new FilterPermanentCard("a permanent card"), false);
}
public PutPermanentOnBattlefieldEffect(FilterCard filter) {
this(filter, false);
}
public PutPermanentOnBattlefieldEffect(FilterCard filter, boolean useTargetController) {
super(Outcome.PutCardInPlay);
this.filter = filter;
this.useTargetController = useTargetController;
}
public PutPermanentOnBattlefieldEffect(final PutPermanentOnBattlefieldEffect effect) {
super(effect);
this.filter = effect.filter.copy();
this.useTargetController = effect.useTargetController;
}
@Override
@ -40,7 +47,13 @@ public class PutPermanentOnBattlefieldEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player player;
if(useTargetController) {
player = game.getPlayer(getTargetPointer().getFirst(game, source));
}
else {
player = game.getPlayer(source.getControllerId());
}
String choiceText = "Put " + filter.getMessage() + " from your hand onto the battlefield?";
if (player == null || !player.chooseUse(Outcome.PutCardInPlay, choiceText, source, game)) {
return false;
@ -63,6 +76,11 @@ public class PutPermanentOnBattlefieldEffect extends OneShotEffect {
return staticText;
}
return "you may put " + filter.getMessage() + " from your hand onto the battlefield";
if(useTargetController) {
return "that player may put " + filter.getMessage() + " from his or her hand onto the battlefield";
}
else {
return "you may put " + filter.getMessage() + " from your hand onto the battlefield";
}
}
}

View file

@ -6,8 +6,11 @@
package mage.abilities.effects.common.continuous;
import java.util.ArrayList;
import java.util.Iterator;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
@ -25,21 +28,23 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
protected ArrayList<String> subtypes = new ArrayList();
protected boolean loseOther; // loses other subtypes
protected FilterCreaturePermanent filter;
public BecomesSubtypeAllEffect(Duration duration, String subtype) {
public BecomesSubtypeAllEffect(Duration duration, String subtype) {
this(duration, createArrayList(subtype));
}
public BecomesSubtypeAllEffect(Duration duration, ArrayList<String> subtypes) {
this(duration, subtypes, true);
this(duration, subtypes, new FilterCreaturePermanent("All creatures"), true);
}
public BecomesSubtypeAllEffect(Duration duration,
ArrayList<String> subtypes, boolean loseOther) {
ArrayList<String> subtypes, FilterCreaturePermanent filter, boolean loseOther) {
super(duration, Outcome.Detriment);
this.subtypes = subtypes;
this.staticText = setText();
this.loseOther = loseOther;
this.filter = filter;
}
private static ArrayList<String> createArrayList(String subtype) {
@ -52,7 +57,7 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
super(effect);
this.subtypes.addAll(effect.subtypes);
this.loseOther = effect.loseOther;
this.loseOther = effect.loseOther;
this.filter = effect.filter;
}
@Override
@ -68,9 +73,7 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source,
Game game) {
for (Permanent permanent : game.getBattlefield()
.getAllActivePermanents(new FilterCreaturePermanent(), game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
if (permanent != null) {
switch (layer) {
case TypeChangingEffects_4:

View file

@ -55,6 +55,7 @@ public enum CounterType {
FEATHER("feather"),
FLOOD("flood"),
FUSE("fuse"),
GOLD("gold"),
HATCHLING("hatchling"),
HOOFPRINT("hoofprint"),
ICE("ice"),

View file

@ -96,6 +96,16 @@ public class Counters extends HashMap<String, Counter> implements Serializable {
}
}
public void removeAllCounters(CounterType counterType){
removeAllCounters(counterType.getName());
}
public void removeAllCounters(String name){
if (this.containsKey(name)){
this.remove(name);
}
}
public int getCount(String name) {
if (this.containsKey(name)) {
return this.get(name).getCount();

View file

@ -1,31 +1,30 @@
/*
* 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.
*/
* 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.filter;
import java.util.ArrayList;
@ -52,7 +51,7 @@ public abstract class FilterImpl<E> implements Filter<E> {
this.message = name;
}
public FilterImpl(FilterImpl filter) {
public FilterImpl(FilterImpl<E> filter) {
this.message = filter.message;
this.predicates = new ArrayList<>(filter.predicates);
}

View file

@ -1,31 +1,30 @@
/*
* 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.
*/
* 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.filter;
import mage.MageObject;
@ -46,7 +45,7 @@ public class FilterObject<E extends MageObject> extends FilterImpl<E> {
super(name);
}
public FilterObject(FilterObject filter) {
public FilterObject(FilterObject<E> filter) {
super(filter);
}
}

View file

@ -34,7 +34,6 @@ import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.target.Target;
import mage.target.Targets;
/**
*
@ -57,7 +56,7 @@ public class NumberOfTargetsPredicate implements Predicate<MageObject> {
Mode mode = spell.getSpellAbility().getModes().get(modeId);
for (Target target : mode.getTargets()) {
numberOfTargets += target.getTargets().size();
}
}
}
if (numberOfTargets == targets) {
return true;

View file

@ -390,6 +390,11 @@ public abstract class GameImpl implements Game, Serializable {
object = state.getBattlefield().getPermanent(objectId);
return object;
}
// can be an ability of a sacrificed Token trying to get it's source object
object = getLastKnownInformation(objectId, Zone.BATTLEFIELD);
if (object != null) {
return object;
}
for (CommandObject commandObject : state.getCommand()) {
if (commandObject instanceof Commander && commandObject.getId().equals(objectId)) {
return commandObject;
@ -402,8 +407,6 @@ public abstract class GameImpl implements Game, Serializable {
return commandObject;
}
}
// can be an ability of a sacrificed Token trying to get it's source object
object = getLastKnownInformation(objectId, Zone.BATTLEFIELD);
}
return object;
}

View file

@ -1,41 +1,45 @@
/*
* 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.
*/
* 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.game.stack;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.EffectType;
import mage.constants.Zone;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.*;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
import mage.abilities.Mode;
import mage.abilities.Modes;
import mage.abilities.StateTriggeredAbility;
import mage.abilities.costs.AlternativeCost;
import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs;
@ -45,19 +49,19 @@ import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.cards.Card;
import mage.choices.Choice;
import mage.choices.Choices;
import mage.game.Game;
import mage.target.Target;
import mage.target.Targets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.cards.Card;
import mage.constants.AbilityType;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.EffectType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.Target;
import mage.target.Targets;
import mage.util.GameLog;
import mage.watchers.Watcher;
@ -96,7 +100,7 @@ public class StackAbility extends StackObjImpl implements Ability {
public boolean isActivated() {
return ability.isActivated();
}
@Override
public boolean resolve(Game game) {
if (ability.getTargets().stillLegal(ability, game)) {
@ -110,13 +114,14 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void reset(Game game) { }
public void reset(Game game) {
}
@Override
public void counter(UUID sourceId, Game game) {
//20100716 - 603.8
if (ability instanceof StateTriggeredAbility) {
((StateTriggeredAbility)ability).counter(game);
((StateTriggeredAbility) ability).counter(game);
}
}
@ -127,14 +132,14 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public String getIdName() {
return getName() + " ["+getId().toString().substring(0,3) +"]";
return getName() + " [" + getId().toString().substring(0, 3) + "]";
}
@Override
public String getLogName() {
return GameLog.getColoredObjectIdName(this);
}
@Override
public String getImageName() {
return name;
@ -221,9 +226,9 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public int getConvertedManaCost() {
// Activated abilities have an "activation cost" but they don't have a characteristic related to that while on the stack.
// Activated abilities have an "activation cost" but they don't have a characteristic related to that while on the stack.
// There are certain effects that interact with the cost to activate an ability (e.g., Training Grounds, Power Artifact)
// but nothing that looks for that quality of an ability once it's on the stack.
// but nothing that looks for that quality of an ability once it's on the stack.
return 0;
}
@ -258,13 +263,16 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void setSourceId(UUID sourceID) {}
public void setSourceId(UUID sourceID) {
}
@Override
public void addCost(Cost cost) {}
public void addCost(Cost cost) {
}
@Override
public void addEffect(Effect effect) {}
public void addEffect(Effect effect) {
}
@Override
public boolean activate(Game game, boolean noMana) {
@ -277,7 +285,8 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void addTarget(Target target) {}
public void addTarget(Target target) {
}
@Override
public UUID getFirstTarget() {
@ -290,7 +299,8 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void addChoice(Choice choice) {}
public void addChoice(Choice choice) {
}
@Override
public List<AlternativeCost> getAlternativeCosts() {
@ -298,7 +308,8 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void addAlternativeCost(AlternativeCost cost) { }
public void addAlternativeCost(AlternativeCost cost) {
}
@Override
public ManaCosts<ManaCost> getManaCosts() {
@ -306,12 +317,13 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public ManaCosts<ManaCost> getManaCostsToPay ( ) {
public ManaCosts<ManaCost> getManaCostsToPay() {
return ability.getManaCostsToPay();
}
@Override
public void addManaCost(ManaCost cost) { }
public void addManaCost(ManaCost cost) {
}
@Override
public AbilityType getAbilityType() {
@ -329,7 +341,7 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void setName(String name) {
public void setName(String name) {
this.name = name;
}
@ -344,7 +356,7 @@ public class StackAbility extends StackObjImpl implements Ability {
card.adjustChoices(ability, game);
}
}
@Override
public void adjustCosts(Ability ability, Game game) {
Card card = game.getCard(ability.getSourceId());
@ -367,7 +379,8 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void addOptionalCost(Cost cost) {}
public void addOptionalCost(Cost cost) {
}
@Override
public boolean checkIfClause(Game game) {
@ -382,7 +395,8 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void newOriginalId() {}
public void newOriginalId() {
}
@Override
public Ability getStackAbility() {
@ -395,7 +409,8 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public void addMode(Mode mode) {}
public void addMode(Mode mode) {
}
@Override
public Modes getModes() {
@ -455,7 +470,7 @@ public class StackAbility extends StackObjImpl implements Ability {
public void setAdditionalCostsRuleVisible(boolean ruleAdditionalCostsVisible) {
this.ability.setAdditionalCostsRuleVisible(ruleAdditionalCostsVisible);
}
@Override
public UUID getOriginalId() {
return this.ability.getOriginalId();
@ -478,7 +493,7 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public void setCostModificationActive(boolean active) {
throw new UnsupportedOperationException("Not supported. Only neede for flashbacked spells");
throw new UnsupportedOperationException("Not supported. Only neede for flashbacked spells");
}
@Override
@ -500,7 +515,7 @@ public class StackAbility extends StackObjImpl implements Ability {
public void addWatcher(Watcher watcher) {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public List<Ability> getSubAbilities() {
return this.ability.getSubAbilities();
@ -513,7 +528,7 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public MageObject getSourceObject(Game game) {
throw new UnsupportedOperationException("Not supported.");
return game.getBaseObject(getSourceId());
}
@Override
@ -529,7 +544,7 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public void setSourceObject(MageObject sourceObject, Game game) {
throw new UnsupportedOperationException("Not supported.");
}
}
@Override
public int getZoneChangeCounter(Game game) {