forked from External/mage
Commander: improved lands compatibility with cost modification and restriction effects;
This commit is contained in:
parent
42ed14df52
commit
97c8622311
8 changed files with 81 additions and 83 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.common.CommanderAdditionalCost;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -18,9 +17,6 @@ public class CastCommanderAbility extends SpellAbility {
|
|||
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||
this.timing = card.getSpellAbility().getTiming();
|
||||
|
||||
// extra cost
|
||||
this.addCost(new CommanderAdditionalCost());
|
||||
} else {
|
||||
throw new IllegalStateException("Cast commander ability must be used with spell ability only: " + card.getName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.PlayLandAbility;
|
||||
import mage.abilities.costs.common.CommanderAdditionalCost;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
|
|
@ -12,9 +11,6 @@ public class PlayLandAsCommanderAbility extends PlayLandAbility {
|
|||
public PlayLandAsCommanderAbility(PlayLandAbility originalAbility) {
|
||||
super(originalAbility);
|
||||
zone = Zone.COMMAND;
|
||||
|
||||
// extra cost
|
||||
this.addCost(new CommanderAdditionalCost());
|
||||
}
|
||||
|
||||
private PlayLandAsCommanderAbility(PlayLandAsCommanderAbility ability) {
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
package mage.abilities.costs.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.CommanderPlaysCount;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class CommanderAdditionalCost extends DynamicValueGenericManaCost {
|
||||
|
||||
/*
|
||||
903.8. A player may cast a commander they own from the command zone. A commander cast from the
|
||||
command zone costs an additional {2} for each previous time the player casting it has cast it from
|
||||
the command zone that game. This additional cost is informally known as the “commander tax.”
|
||||
*/
|
||||
|
||||
public CommanderAdditionalCost() {
|
||||
super(new CommanderPlaysCount(2), "{2} for each previous time the player casting it has cast it from the command zone");
|
||||
}
|
||||
|
||||
public CommanderAdditionalCost(final CommanderAdditionalCost cost) {
|
||||
super(cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommanderAdditionalCost copy() {
|
||||
return new CommanderAdditionalCost(this);
|
||||
}
|
||||
|
||||
public boolean isEmptyPay(Ability ability, Game game) {
|
||||
return amount.calculate(game, ability, null) == 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.CastCommanderAbility;
|
||||
import mage.abilities.common.PlayLandAsCommanderAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.CommanderPlaysCountWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Plopman
|
||||
*/
|
||||
/*
|
||||
903.8. A player may cast a commander they own from the command zone. A commander cast from the
|
||||
command zone costs an additional {2} for each previous time the player casting it has cast it from
|
||||
the command zone that game. This additional cost is informally known as the “commander tax.”
|
||||
*/
|
||||
public class CommanderCostModification extends CostModificationEffectImpl {
|
||||
|
||||
private final UUID commanderId;
|
||||
|
||||
public CommanderCostModification(UUID commanderId) {
|
||||
super(Duration.Custom, Outcome.Neutral, CostModificationType.INCREASE_COST);
|
||||
this.commanderId = commanderId;
|
||||
}
|
||||
|
||||
public CommanderCostModification(final CommanderCostModification effect) {
|
||||
super(effect);
|
||||
this.commanderId = effect.commanderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class);
|
||||
int castCount = watcher.getPlaysCount(commanderId);
|
||||
if (castCount > 0) {
|
||||
abilityToModify.getManaCostsToPay().add(new GenericManaCost(2 * castCount));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return commanderId.equals(abilityToModify.getSourceId())
|
||||
&& (abilityToModify instanceof CastCommanderAbility || abilityToModify instanceof PlayLandAsCommanderAbility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommanderCostModification copy() {
|
||||
return new CommanderCostModification(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue