fixes and cleanup

This commit is contained in:
BetaSteward 2010-11-09 03:38:55 +00:00
parent 304b7404cf
commit f13c9bc3bb
16 changed files with 75 additions and 35 deletions

View file

@ -100,7 +100,7 @@ class FinestHourAbility extends TriggeredAbilityImpl<FinestHourAbility> {
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;
}

View file

@ -88,7 +88,7 @@ class FontOfMythosAbility extends TriggeredAbilityImpl<FontOfMythosAbility> {
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;
}

View file

@ -89,7 +89,10 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
@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)) {

View file

@ -87,7 +87,7 @@ class HowlingMineAbility extends TriggeredAbilityImpl<HowlingMineAbility> {
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;
}

View file

@ -88,7 +88,7 @@ class LilianasCaressAbility extends TriggeredAbilityImpl<LilianasCaressAbility>
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;
}

View file

@ -101,7 +101,7 @@ class RafiqOfTheManyAbility extends TriggeredAbilityImpl<RafiqOfTheManyAbility>
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;
}

View file

@ -132,7 +132,9 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> 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<T extends AbilityImpl<T>> 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");

View file

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

View file

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

View file

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

View file

@ -46,5 +46,6 @@ public interface ContinuousEffect<T extends ContinuousEffect<T>> 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);
}

View file

@ -97,4 +97,7 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
return used;
}
@Override
public void init(Ability source, Game game) {}
}

View file

@ -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<T extends Effect<T>> extends Serializable {
// public UUID getId();
public String getText(Ability source);
public boolean apply(Game game, Ability source);
public Outcome getOutcome();
public T copy();
}

View file

@ -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<T extends Effect<T>> implements Effect<T> {
// 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<T extends Effect<T>> implements Effect<T> {
return "";
}
// @Override
// public UUID getId() {
// return id;
// }
@Override
public Outcome getOutcome() {
return outcome;

View file

@ -62,7 +62,7 @@ public class ExaltedAbility extends TriggeredAbilityImpl<ExaltedAbility> {
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;
}

View file

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