forked from External/mage
* Heartsone - Fixed that mana cost was reduced to less than one mana (fixes #7070).
This commit is contained in:
parent
dd7c1939d3
commit
dfa035d9dc
6 changed files with 39 additions and 43 deletions
|
|
@ -74,14 +74,7 @@ class BiomancersFamiliarCostReductionEffect extends CostModificationEffectImpl {
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(abilityToModify.getManaCostsToPay().getMana(), 2, 1);
|
||||||
int reduceMax = mana.getGeneric();
|
|
||||||
if (reduceMax > 0 && mana.count() == mana.getGeneric()) {
|
|
||||||
reduceMax--;
|
|
||||||
}
|
|
||||||
if (reduceMax > 2) {
|
|
||||||
reduceMax = 2;
|
|
||||||
}
|
|
||||||
if (reduceMax <= 0) {
|
if (reduceMax <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Mana;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author pcasaretto_at_gmail.com
|
* @author pcasaretto_at_gmail.com
|
||||||
|
|
@ -42,8 +43,7 @@ public final class Heartstone extends CardImpl {
|
||||||
class HeartstoneEffect extends CostModificationEffectImpl {
|
class HeartstoneEffect extends CostModificationEffectImpl {
|
||||||
|
|
||||||
private static final String effectText = "Activated abilities of creatures cost "
|
private static final String effectText = "Activated abilities of creatures cost "
|
||||||
+ "{1} less to activate. This effect can't reduce the mana in that cost to less than one mana.";
|
+ "{1} less to activate. This effect can't reduce the mana in that cost to less than one mana";
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
|
||||||
|
|
||||||
public HeartstoneEffect() {
|
public HeartstoneEffect() {
|
||||||
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||||
|
|
@ -58,7 +58,11 @@ class HeartstoneEffect extends CostModificationEffectImpl {
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
CardUtil.reduceCost(abilityToModify, 1);
|
int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(abilityToModify.getManaCostsToPay().getMana(), 1, 1);
|
||||||
|
if (reduceMax <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CardUtil.reduceCost(abilityToModify, reduceMax);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -71,10 +75,7 @@ class HeartstoneEffect extends CostModificationEffectImpl {
|
||||||
&& (abilityToModify instanceof ActivatedAbility))) {
|
&& (abilityToModify instanceof ActivatedAbility))) {
|
||||||
// Activated abilities of creatures
|
// Activated abilities of creatures
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(abilityToModify.getSourceId());
|
Permanent permanent = game.getPermanentOrLKIBattlefield(abilityToModify.getSourceId());
|
||||||
if (permanent != null
|
return permanent != null && permanent.isCreature();
|
||||||
&& filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ public final class PowerArtifact extends CardImpl {
|
||||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Enchanted artifact's activated abilities cost less to activate.
|
// Enchanted artifact's activated abilities cost {2} less to activate.
|
||||||
// This effect can't reduce the amount of mana an ability costs to activate to less than one mana.
|
// This effect can't reduce the mana in that cost to less than one mana.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PowerArtifactCostModificationEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PowerArtifactCostModificationEffect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ class PowerArtifactCostModificationEffect extends CostModificationEffectImpl {
|
||||||
PowerArtifactCostModificationEffect() {
|
PowerArtifactCostModificationEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||||
staticText = "Enchanted artifact's activated abilities cost {2} less to activate. "
|
staticText = "Enchanted artifact's activated abilities cost {2} less to activate. "
|
||||||
+ "This effect can't reduce the amount of mana an ability costs to activate to less than one mana.";
|
+ "This effect can't reduce the mana in that cost to less than one mana";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,15 +67,11 @@ class PowerArtifactCostModificationEffect extends CostModificationEffectImpl {
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(abilityToModify.getManaCostsToPay().getMana(), 2, 1);
|
||||||
int reduce = mana.getGeneric();
|
if (reduceMax <= 0) {
|
||||||
if (reduce > 0 && mana.count() == mana.getGeneric()) {
|
return true;
|
||||||
reduce--;
|
}
|
||||||
}
|
CardUtil.reduceCost(abilityToModify, reduceMax);
|
||||||
if (reduce > 2) {
|
|
||||||
reduce = 2;
|
|
||||||
}
|
|
||||||
CardUtil.reduceCost(abilityToModify, reduce);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,7 @@ class TrainingGroundsEffect extends CostModificationEffectImpl {
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(abilityToModify.getManaCostsToPay().getMana(), 2, 1);
|
||||||
int reduceMax = mana.getGeneric();
|
|
||||||
if (reduceMax > 0 && mana.count() == mana.getGeneric()) {
|
|
||||||
reduceMax--;
|
|
||||||
}
|
|
||||||
if (reduceMax > 2) {
|
|
||||||
reduceMax = 2;
|
|
||||||
}
|
|
||||||
if (reduceMax <= 0) {
|
if (reduceMax <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class ZirdaTheDawnwakerEffect extends CostModificationEffectImpl {
|
||||||
ZirdaTheDawnwakerEffect() {
|
ZirdaTheDawnwakerEffect() {
|
||||||
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||||
staticText = "Abilities you activate that aren't mana abilities cost {2} less to activate. "
|
staticText = "Abilities you activate that aren't mana abilities cost {2} less to activate. "
|
||||||
+ "This effect can't reduce the mana in that cost to less than one mana.";
|
+ "This effect can't reduce the mana in that cost to less than one mana";
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZirdaTheDawnwakerEffect(final ZirdaTheDawnwakerEffect effect) {
|
private ZirdaTheDawnwakerEffect(final ZirdaTheDawnwakerEffect effect) {
|
||||||
|
|
@ -100,13 +100,7 @@ class ZirdaTheDawnwakerEffect extends CostModificationEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(abilityToModify.getManaCostsToPay().getMana(), 2, 1);
|
||||||
int reduceMax = mana.getGeneric();
|
|
||||||
if (reduceMax > 0
|
|
||||||
&& mana.count() == mana.getGeneric()) {
|
|
||||||
reduceMax--;
|
|
||||||
}
|
|
||||||
reduceMax = Math.min(reduceMax, 2);
|
|
||||||
if (reduceMax <= 0) {
|
if (reduceMax <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,25 @@ public final class CardUtil {
|
||||||
adjustAbilityCost(ability, -increaseCount);
|
adjustAbilityCost(ability, -increaseCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calculates the maximal possible generic mana reduction for a given mana cost
|
||||||
|
*
|
||||||
|
* @param mana mana costs that should be reduced
|
||||||
|
* @param maxPossibleReduction max possible generic mana reduction
|
||||||
|
* @param notLessThan the complete costs may not be reduced more than this CMC mana costs
|
||||||
|
*/
|
||||||
|
public static int calculateActualPossibleGenericManaReduction(Mana mana, int maxPossibleReduction, int notLessThan) {
|
||||||
|
int nonGeneric = mana.count() - mana.getGeneric();
|
||||||
|
int notPossibleGenericReduction = Math.max(0, notLessThan - nonGeneric);
|
||||||
|
int actualPossibleGenericManaReduction = Math.max(0, mana.getGeneric() - notPossibleGenericReduction);
|
||||||
|
if (actualPossibleGenericManaReduction > maxPossibleReduction) {
|
||||||
|
actualPossibleGenericManaReduction = maxPossibleReduction;
|
||||||
|
}
|
||||||
|
return actualPossibleGenericManaReduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reduces ability cost to be paid.
|
* Reduces ability cost to be paid.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue