Cost increasing abilities were put into wrong layer.
Fix YourCostIncrease and CostIncrease ignoring reduction cost/amount. Enhance cost reduction to support colored-mana-cost reduction.master
parent
6b295a9eba
commit
dd3f975c9d
|
@ -512,11 +512,11 @@ public enum MagicAbility {
|
|||
card.add(MagicHandCastActivation.reduction(cardDef, ARG.number(arg), cond));
|
||||
}
|
||||
},
|
||||
YourCardLessToCast(ARG.WORDRUN + " you cast cost \\{" + ARG.NUMBER + "\\} less to cast\\.", 10) {
|
||||
YourCardLessToCast(ARG.WORDRUN + " you cast cost " + ARG.MANACOST + " less to cast\\.", 10) {
|
||||
@Override
|
||||
protected void addAbilityImpl(final MagicAbilityStore card, final Matcher arg) {
|
||||
final String cards = ARG.wordrun(arg).replaceAll("[Ss]pells", "cards") + " from your hand";
|
||||
card.add(MagicStatic.YourCostReduction(MagicTargetFilterFactory.Card(cards), ARG.number(arg)));
|
||||
card.add(MagicStatic.YourCostReduction(MagicTargetFilterFactory.Card(cards), MagicManaCost.create(ARG.manacost(arg))));
|
||||
}
|
||||
},
|
||||
YourCardMoreToCast(ARG.WORDRUN + " you cast cost " + ARG.MANACOST + " more to cast\\.", 10) {
|
||||
|
|
|
@ -416,4 +416,25 @@ public class MagicManaCost implements MagicCopyable {
|
|||
return MagicManaCost.create(getCanonicalText(reducedAmounts, XCount));
|
||||
}
|
||||
}
|
||||
|
||||
/** Return cost increased by some other cost. Basically sum of those two costs */
|
||||
public MagicManaCost increasedBy(MagicManaCost extraCost) {
|
||||
MagicManaCost res = this;
|
||||
for (final MagicCostManaType cmt : extraCost.getCostManaTypes(0)) {
|
||||
res = res.increase(cmt, 1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cost decreased by some other cost. Only identical mana is removed from the cost.
|
||||
* For example, cost {R}{B} reduced by {B}{B}{1} will become {R}
|
||||
*/
|
||||
public MagicManaCost reducedBy(MagicManaCost extraCost) {
|
||||
MagicManaCost res = this;
|
||||
for (final MagicCostManaType cmt : extraCost.getCostManaTypes(0)) {
|
||||
res = res.reduce(cmt, 1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -553,48 +553,40 @@ public abstract class MagicStatic extends MagicDummyModifier implements MagicCha
|
|||
};
|
||||
}
|
||||
|
||||
public static MagicStatic YourCostReduction(final MagicTargetFilter<MagicCard> filter, int n) {
|
||||
public static MagicStatic YourCostReduction(final MagicTargetFilter<MagicCard> filter, final MagicManaCost cost) {
|
||||
return new MagicStatic(MagicLayer.CostReduction) {
|
||||
@Override
|
||||
public MagicManaCost reduceCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost) {
|
||||
public MagicManaCost reduceCost(final MagicPermanent source, final MagicCard card, final MagicManaCost originalCost) {
|
||||
if (filter.accept(source, source.getController(), card) && source.isFriend(card)) {
|
||||
return cost.reduce(n);
|
||||
return originalCost.reducedBy(cost);
|
||||
} else {
|
||||
return cost;
|
||||
return originalCost;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static MagicStatic YourCostIncrease(final MagicTargetFilter<MagicCard> filter, final MagicManaCost cost) {
|
||||
return new MagicStatic(MagicLayer.CostReduction) {
|
||||
return new MagicStatic(MagicLayer.CostIncrease) {
|
||||
@Override
|
||||
public MagicManaCost reduceCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost) {
|
||||
public MagicManaCost increaseCost(final MagicPermanent source, final MagicCard card, final MagicManaCost originalCost) {
|
||||
if (filter.accept(source, source.getController(), card) && source.isFriend(card)) {
|
||||
MagicManaCost res = cost;
|
||||
for (final MagicCostManaType cmt : cost.getCostManaTypes(0)) {
|
||||
res = cost.increase(cmt, 1);
|
||||
}
|
||||
return res;
|
||||
return originalCost.increasedBy(cost);
|
||||
} else {
|
||||
return cost;
|
||||
return originalCost;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static MagicStatic CostIncrease(final MagicTargetFilter<MagicCard> filter, final MagicManaCost cost) {
|
||||
return new MagicStatic(MagicLayer.CostReduction) {
|
||||
return new MagicStatic(MagicLayer.CostIncrease) {
|
||||
@Override
|
||||
public MagicManaCost reduceCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost) {
|
||||
public MagicManaCost increaseCost(final MagicPermanent source, final MagicCard card, final MagicManaCost originalCost) {
|
||||
if (filter.accept(source, source.getController(), card)) {
|
||||
MagicManaCost res = cost;
|
||||
for (final MagicCostManaType cmt : cost.getCostManaTypes(0)) {
|
||||
res = cost.increase(cmt, 1);
|
||||
}
|
||||
return res;
|
||||
return originalCost.increasedBy(cost);
|
||||
} else {
|
||||
return cost;
|
||||
return originalCost;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue