* Cost reduction effects - fixed that some cards with cost reduction can't be played (example: Price of Fame, see #6685, #6684);

This commit is contained in:
Oleg Agafonov 2020-06-27 05:40:45 +04:00
parent 2252648f01
commit 520d75dba9
7 changed files with 70 additions and 32 deletions

View file

@ -1,27 +1,28 @@
package mage.abilities.effects.common.cost;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.CostModificationEffect;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Outcome;
import mage.game.Game;
/**
* Simple implementation of a {@link CostModificationEffect} offering simplified
* construction to setup the object for use by the mage framework.
*
* @author maurer.it_at_gmail.com
*/
public abstract class CostModificationEffectImpl extends ContinuousEffectImpl implements CostModificationEffect {
private final CostModificationType modificationType;
public CostModificationEffectImpl ( Duration duration, Outcome outcome, CostModificationType type) {
// if effect need real stack object to check then mark it as stack only (example: apply cost reduction if you target human creature)
private boolean worksOnStackOnly = false;
public CostModificationEffectImpl(Duration duration, Outcome outcome, CostModificationType type) {
super(duration, outcome);
this.effectType = EffectType.COSTMODIFICATION;
this.modificationType = type;
@ -30,23 +31,33 @@ public abstract class CostModificationEffectImpl extends ContinuousEffectImpl im
public CostModificationEffectImpl(final CostModificationEffectImpl effect) {
super(effect);
this.modificationType = effect.modificationType;
this.worksOnStackOnly = effect.worksOnStackOnly;
}
/**
* Overridden and 'no-op' implementation put in place.
*
* @see #apply(mage.game.Game, mage.abilities.Ability, mage.abilities.Ability)
*
* @param game
* @param source
* @return
* @see #apply(mage.game.Game, mage.abilities.Ability, mage.abilities.Ability)
*/
@Override
public final boolean apply ( Game game, Ability source ) { return false; }
public final boolean apply(Game game, Ability source) {
return false;
}
@Override
public CostModificationType getModificationType(){
public CostModificationType getModificationType() {
return this.modificationType;
}
public CostModificationEffectImpl setCanWorksOnStackOnly(boolean worksOnStackOnly) {
this.worksOnStackOnly = worksOnStackOnly;
return this;
}
public boolean canWorksOnStackOnly() {
return this.worksOnStackOnly;
}
}

View file

@ -93,7 +93,9 @@ public class SpellCostReductionSourceEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify.getSourceId().equals(source.getSourceId()) && (abilityToModify instanceof SpellAbility)) {
return condition == null || condition.apply(game, source);
// some conditions can works after put on stack, so skip it in get playable (allows user to put card on stack anyway)
boolean skipCondition = game.inCheckPlayableState() && canWorksOnStackOnly();
return condition == null || skipCondition || condition.apply(game, source);
}
return false;
}