diff --git a/Mage.Sets/src/mage/sets/alarareborn/FinestHour.java b/Mage.Sets/src/mage/sets/alarareborn/FinestHour.java index 166df51fb8..5cd70edf17 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/FinestHour.java +++ b/Mage.Sets/src/mage/sets/alarareborn/FinestHour.java @@ -100,7 +100,7 @@ class FinestHourAbility extends TriggeredAbilityImpl { if (event.getType() == EventType.DECLARED_ATTACKERS) { if (game.getCombat().attacksAlone()) { this.addTarget(new TargetCreaturePermanent()); - this.targets.get(0).addTarget(game.getCombat().getAttackers().get(0), this, game); + this.targets.get(0).add(game.getCombat().getAttackers().get(0), game); trigger(game, event.getPlayerId()); return true; } diff --git a/Mage.Sets/src/mage/sets/conflux/FontOfMythos.java b/Mage.Sets/src/mage/sets/conflux/FontOfMythos.java index c57a570177..90a2a785c7 100644 --- a/Mage.Sets/src/mage/sets/conflux/FontOfMythos.java +++ b/Mage.Sets/src/mage/sets/conflux/FontOfMythos.java @@ -88,7 +88,7 @@ class FontOfMythosAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == EventType.DRAW_STEP_PRE) { this.addTarget(new TargetPlayer()); - this.targets.get(0).addTarget(event.getPlayerId(), this, game); + this.targets.get(0).add(event.getPlayerId(),game); trigger(game, event.getPlayerId()); return true; } diff --git a/Mage.Sets/src/mage/sets/conflux/MartialCoup.java b/Mage.Sets/src/mage/sets/conflux/MartialCoup.java index 1e8278d0b8..d8b2f95a43 100644 --- a/Mage.Sets/src/mage/sets/conflux/MartialCoup.java +++ b/Mage.Sets/src/mage/sets/conflux/MartialCoup.java @@ -89,7 +89,10 @@ class MartialCoupEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = source.getCosts().getVariableCosts().get(0).getAmount(); + int amount = 0; + if (source.getCosts().getVariableCosts().size() > 0) { + amount = source.getCosts().getVariableCosts().get(0).getAmount(); + } if (amount > 4) { for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/sets/magic2010/HowlingMine.java b/Mage.Sets/src/mage/sets/magic2010/HowlingMine.java index 39cd9bc30d..f5db12c4ed 100644 --- a/Mage.Sets/src/mage/sets/magic2010/HowlingMine.java +++ b/Mage.Sets/src/mage/sets/magic2010/HowlingMine.java @@ -87,7 +87,7 @@ class HowlingMineAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == EventType.DRAW_STEP_PRE) { this.addTarget(new TargetPlayer()); - this.targets.get(0).addTarget(event.getPlayerId(), null, game); + this.targets.get(0).add(event.getPlayerId(), game); trigger(game, event.getPlayerId()); return true; } diff --git a/Mage.Sets/src/mage/sets/magic2011/LilianasCaress.java b/Mage.Sets/src/mage/sets/magic2011/LilianasCaress.java index 7f32f53da6..1234e6d439 100644 --- a/Mage.Sets/src/mage/sets/magic2011/LilianasCaress.java +++ b/Mage.Sets/src/mage/sets/magic2011/LilianasCaress.java @@ -88,7 +88,7 @@ class LilianasCaressAbility extends TriggeredAbilityImpl public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == EventType.DISCARDED_CARD && game.getOpponents(controllerId).contains(event.getPlayerId())) { this.addTarget(new TargetPlayer()); - this.targets.get(0).addTarget(event.getPlayerId(), this, game); + this.targets.get(0).add(event.getPlayerId(), game); trigger(game, event.getPlayerId()); return true; } diff --git a/Mage.Sets/src/mage/sets/shardsofalara/RafiqOfTheMany.java b/Mage.Sets/src/mage/sets/shardsofalara/RafiqOfTheMany.java index 999a684708..b71448b606 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/RafiqOfTheMany.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/RafiqOfTheMany.java @@ -101,7 +101,7 @@ class RafiqOfTheManyAbility extends TriggeredAbilityImpl if (event.getType() == EventType.DECLARED_ATTACKERS && game.getActivePlayerId().equals(this.controllerId) ) { if (game.getCombat().attacksAlone()) { this.addTarget(new TargetCreaturePermanent()); - this.targets.get(0).addTarget(game.getCombat().getAttackers().get(0), null, game); + this.targets.get(0).add(game.getCombat().getAttackers().get(0), game); trigger(game, event.getPlayerId()); return true; } diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index b4490313ce..c851e32d3b 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -132,7 +132,9 @@ public abstract class AbilityImpl> implements Ability { result &= effect.apply(game, this); } else { - game.addEffect((ContinuousEffect) effect, this); + ContinuousEffect cEffect = (ContinuousEffect) effect; + cEffect.init(this, game); + game.addEffect(cEffect, this); } } } @@ -146,19 +148,6 @@ public abstract class AbilityImpl> implements Ability { logger.fine("activate failed - choice"); return false; } - //20100716 - 114.1b -// if (game.getObject(sourceId).getSubtype().contains("Aura")) { -// for (Ability ability: game.getObject(sourceId).getAbilities()) { -// if (ability instanceof EnchantAbility) { -// Targets enchantTargets = ability.getTargets(); -// if (enchantTargets.size() > 0 && enchantTargets.chooseTargets(ability.getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) { -// logger.fine("activate failed - target"); -// return false; -// } -// break; -// } -// } -// } //20100716 - 601.2b if (targets.size() > 0 && targets.chooseTargets(effects.get(0).getOutcome(), this.controllerId, this, game) == false) { logger.fine("activate failed - target"); diff --git a/Mage/src/mage/abilities/costs/common/DiscardTargetCost.java b/Mage/src/mage/abilities/costs/common/DiscardTargetCost.java index 36e17b9b0e..ad53df9520 100644 --- a/Mage/src/mage/abilities/costs/common/DiscardTargetCost.java +++ b/Mage/src/mage/abilities/costs/common/DiscardTargetCost.java @@ -30,7 +30,6 @@ package mage.abilities.costs.common; import java.util.UUID; import mage.Constants.Outcome; -import mage.abilities.Ability; import mage.abilities.costs.CostImpl; import mage.cards.Card; import mage.game.Game; diff --git a/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java b/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java index b61da7a322..6cf56898b8 100644 --- a/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java +++ b/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import mage.Constants.Outcome; -import mage.abilities.Ability; import mage.abilities.costs.CostImpl; import mage.game.Game; import mage.game.permanent.Permanent; diff --git a/Mage/src/mage/abilities/costs/common/TapTargetCost.java b/Mage/src/mage/abilities/costs/common/TapTargetCost.java index a2e0d8d116..4b27219aa0 100644 --- a/Mage/src/mage/abilities/costs/common/TapTargetCost.java +++ b/Mage/src/mage/abilities/costs/common/TapTargetCost.java @@ -30,7 +30,6 @@ package mage.abilities.costs.common; import java.util.UUID; import mage.Constants.Outcome; -import mage.abilities.Ability; import mage.abilities.costs.CostImpl; import mage.game.Game; import mage.game.permanent.Permanent; diff --git a/Mage/src/mage/abilities/effects/ContinuousEffect.java b/Mage/src/mage/abilities/effects/ContinuousEffect.java index 317bdde4ef..48ef5019fa 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffect.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffect.java @@ -46,5 +46,6 @@ public interface ContinuousEffect> extends Effect< public Date getTimestamp(); public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game); public boolean hasLayer(Layer layer); + public void init(Ability source, Game game); } diff --git a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java index d0b300624a..47a5c7c967 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java @@ -97,4 +97,7 @@ public abstract class ContinuousEffectImpl> ex return used; } + @Override + public void init(Ability source, Game game) {} + } diff --git a/Mage/src/mage/abilities/effects/Effect.java b/Mage/src/mage/abilities/effects/Effect.java index ed1700da7f..6765b2e361 100644 --- a/Mage/src/mage/abilities/effects/Effect.java +++ b/Mage/src/mage/abilities/effects/Effect.java @@ -29,7 +29,6 @@ package mage.abilities.effects; import java.io.Serializable; -import java.util.UUID; import mage.Constants.Outcome; import mage.abilities.Ability; import mage.game.Game; @@ -40,10 +39,10 @@ import mage.game.Game; */ public interface Effect> extends Serializable { -// public UUID getId(); public String getText(Ability source); public boolean apply(Game game, Ability source); public Outcome getOutcome(); public T copy(); + } diff --git a/Mage/src/mage/abilities/effects/EffectImpl.java b/Mage/src/mage/abilities/effects/EffectImpl.java index f2942dd269..ed31d6294f 100644 --- a/Mage/src/mage/abilities/effects/EffectImpl.java +++ b/Mage/src/mage/abilities/effects/EffectImpl.java @@ -28,7 +28,6 @@ package mage.abilities.effects; -import java.util.UUID; import mage.Constants.Outcome; import mage.abilities.Ability; @@ -38,16 +37,13 @@ import mage.abilities.Ability; */ public abstract class EffectImpl> implements Effect { -// protected final UUID id; protected final Outcome outcome; public EffectImpl(Outcome outcome) { -// this.id = UUID.randomUUID(); this.outcome = outcome; } public EffectImpl(final EffectImpl effect) { -// this.id = effect.id; this.outcome = effect.outcome; } @@ -56,11 +52,6 @@ public abstract class EffectImpl> implements Effect { return ""; } -// @Override -// public UUID getId() { -// return id; -// } - @Override public Outcome getOutcome() { return outcome; diff --git a/Mage/src/mage/abilities/keyword/ExaltedAbility.java b/Mage/src/mage/abilities/keyword/ExaltedAbility.java index 143d8dfd6f..19f5c30d6f 100644 --- a/Mage/src/mage/abilities/keyword/ExaltedAbility.java +++ b/Mage/src/mage/abilities/keyword/ExaltedAbility.java @@ -62,7 +62,7 @@ public class ExaltedAbility extends TriggeredAbilityImpl { if (game.getCombat().attacksAlone()) { TargetCreaturePermanent target = new TargetCreaturePermanent(); this.addTarget(target); - this.getTargets().get(0).addTarget(game.getCombat().getAttackers().get(0), null, game); + this.getTargets().get(0).add(game.getCombat().getAttackers().get(0),game); trigger(game, event.getPlayerId()); return true; } diff --git a/Mage/src/mage/abilities/keyword/MountainwalkAbility.java b/Mage/src/mage/abilities/keyword/MountainwalkAbility.java new file mode 100644 index 0000000000..19b2f306b7 --- /dev/null +++ b/Mage/src/mage/abilities/keyword/MountainwalkAbility.java @@ -0,0 +1,57 @@ +/* + * 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.keyword; + +import java.io.ObjectStreamException; +import mage.filter.Filter.ComparisonScope; +import mage.filter.common.FilterLandPermanent; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class MountainwalkAbility extends LandwalkAbility { + + private static final MountainwalkAbility fINSTANCE = new MountainwalkAbility(); + + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } + + public static MountainwalkAbility getInstance() { + return fINSTANCE; + } + + private MountainwalkAbility() { + filter = new FilterLandPermanent("Mountain"); + filter.getSubtype().add("Mountain"); + filter.setScopeSubtype(ComparisonScope.Any); + } + +} \ No newline at end of file