mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
fixes and cleanup
This commit is contained in:
parent
304b7404cf
commit
f13c9bc3bb
16 changed files with 75 additions and 35 deletions
|
@ -100,7 +100,7 @@ class FinestHourAbility extends TriggeredAbilityImpl<FinestHourAbility> {
|
||||||
if (event.getType() == EventType.DECLARED_ATTACKERS) {
|
if (event.getType() == EventType.DECLARED_ATTACKERS) {
|
||||||
if (game.getCombat().attacksAlone()) {
|
if (game.getCombat().attacksAlone()) {
|
||||||
this.addTarget(new TargetCreaturePermanent());
|
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());
|
trigger(game, event.getPlayerId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ class FontOfMythosAbility extends TriggeredAbilityImpl<FontOfMythosAbility> {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.DRAW_STEP_PRE) {
|
if (event.getType() == EventType.DRAW_STEP_PRE) {
|
||||||
this.addTarget(new TargetPlayer());
|
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());
|
trigger(game, event.getPlayerId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,10 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
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) {
|
if (amount > 4) {
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), source.getControllerId(), game)) {
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), source.getControllerId(), game)) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ class HowlingMineAbility extends TriggeredAbilityImpl<HowlingMineAbility> {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.DRAW_STEP_PRE) {
|
if (event.getType() == EventType.DRAW_STEP_PRE) {
|
||||||
this.addTarget(new TargetPlayer());
|
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());
|
trigger(game, event.getPlayerId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ class LilianasCaressAbility extends TriggeredAbilityImpl<LilianasCaressAbility>
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.DISCARDED_CARD && game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
if (event.getType() == EventType.DISCARDED_CARD && game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
||||||
this.addTarget(new TargetPlayer());
|
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());
|
trigger(game, event.getPlayerId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ class RafiqOfTheManyAbility extends TriggeredAbilityImpl<RafiqOfTheManyAbility>
|
||||||
if (event.getType() == EventType.DECLARED_ATTACKERS && game.getActivePlayerId().equals(this.controllerId) ) {
|
if (event.getType() == EventType.DECLARED_ATTACKERS && game.getActivePlayerId().equals(this.controllerId) ) {
|
||||||
if (game.getCombat().attacksAlone()) {
|
if (game.getCombat().attacksAlone()) {
|
||||||
this.addTarget(new TargetCreaturePermanent());
|
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());
|
trigger(game, event.getPlayerId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,9 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
result &= effect.apply(game, this);
|
result &= effect.apply(game, this);
|
||||||
}
|
}
|
||||||
else {
|
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");
|
logger.fine("activate failed - choice");
|
||||||
return false;
|
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
|
//20100716 - 601.2b
|
||||||
if (targets.size() > 0 && targets.chooseTargets(effects.get(0).getOutcome(), this.controllerId, this, game) == false) {
|
if (targets.size() > 0 && targets.chooseTargets(effects.get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||||
logger.fine("activate failed - target");
|
logger.fine("activate failed - target");
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.abilities.costs.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.costs.CostImpl;
|
import mage.abilities.costs.CostImpl;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.costs.CostImpl;
|
import mage.abilities.costs.CostImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.abilities.costs.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.costs.CostImpl;
|
import mage.abilities.costs.CostImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
|
@ -46,5 +46,6 @@ public interface ContinuousEffect<T extends ContinuousEffect<T>> extends Effect<
|
||||||
public Date getTimestamp();
|
public Date getTimestamp();
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game);
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game);
|
||||||
public boolean hasLayer(Layer layer);
|
public boolean hasLayer(Layer layer);
|
||||||
|
public void init(Ability source, Game game);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,4 +97,7 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
|
||||||
return used;
|
return used;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Ability source, Game game) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -40,10 +39,10 @@ import mage.game.Game;
|
||||||
*/
|
*/
|
||||||
public interface Effect<T extends Effect<T>> extends Serializable {
|
public interface Effect<T extends Effect<T>> extends Serializable {
|
||||||
|
|
||||||
// public UUID getId();
|
|
||||||
public String getText(Ability source);
|
public String getText(Ability source);
|
||||||
public boolean apply(Game game, Ability source);
|
public boolean apply(Game game, Ability source);
|
||||||
public Outcome getOutcome();
|
public Outcome getOutcome();
|
||||||
|
|
||||||
public T copy();
|
public T copy();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
||||||
|
@ -38,16 +37,13 @@ import mage.abilities.Ability;
|
||||||
*/
|
*/
|
||||||
public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
||||||
|
|
||||||
// protected final UUID id;
|
|
||||||
protected final Outcome outcome;
|
protected final Outcome outcome;
|
||||||
|
|
||||||
public EffectImpl(Outcome outcome) {
|
public EffectImpl(Outcome outcome) {
|
||||||
// this.id = UUID.randomUUID();
|
|
||||||
this.outcome = outcome;
|
this.outcome = outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EffectImpl(final EffectImpl effect) {
|
public EffectImpl(final EffectImpl effect) {
|
||||||
// this.id = effect.id;
|
|
||||||
this.outcome = effect.outcome;
|
this.outcome = effect.outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +52,6 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public UUID getId() {
|
|
||||||
// return id;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Outcome getOutcome() {
|
public Outcome getOutcome() {
|
||||||
return outcome;
|
return outcome;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ExaltedAbility extends TriggeredAbilityImpl<ExaltedAbility> {
|
||||||
if (game.getCombat().attacksAlone()) {
|
if (game.getCombat().attacksAlone()) {
|
||||||
TargetCreaturePermanent target = new TargetCreaturePermanent();
|
TargetCreaturePermanent target = new TargetCreaturePermanent();
|
||||||
this.addTarget(target);
|
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());
|
trigger(game, event.getPlayerId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
57
Mage/src/mage/abilities/keyword/MountainwalkAbility.java
Normal file
57
Mage/src/mage/abilities/keyword/MountainwalkAbility.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue