add support for static effects that increase/decrease mana cost
does not work on additional mana costs such as kicker and {X} in costmaster
parent
3ead46bee8
commit
e1a48ef015
|
@ -18,6 +18,7 @@ import magic.model.event.MagicTiming;
|
|||
import magic.model.mstatic.MagicCDA;
|
||||
import magic.model.mstatic.MagicStatic;
|
||||
import magic.model.trigger.MagicTrigger;
|
||||
import magic.model.trigger.MagicTriggerType;
|
||||
import magic.model.trigger.EntersBattlefieldTrigger;
|
||||
import magic.model.trigger.EntersWithCounterTrigger;
|
||||
import magic.model.trigger.ThisDrawnTrigger;
|
||||
|
@ -661,10 +662,12 @@ public class MagicCardDefinition implements MagicAbilityStore, IRenderableCard {
|
|||
|
||||
public List<MagicEvent> getCostEvent(final MagicCard source) {
|
||||
final List<MagicEvent> costEvent = new ArrayList<MagicEvent>();
|
||||
if (cost != MagicManaCost.ZERO) {
|
||||
final MagicManaCost modCost = source.getGame().modCost(source, cost);
|
||||
|
||||
if (modCost != MagicManaCost.ZERO) {
|
||||
costEvent.add(new MagicPayManaCostEvent(
|
||||
source,
|
||||
cost
|
||||
modCost
|
||||
));
|
||||
}
|
||||
costEvent.addAll(getAdditionalCostEvent(source));
|
||||
|
|
|
@ -583,6 +583,17 @@ public class MagicGame {
|
|||
doDelayedActions();
|
||||
}
|
||||
|
||||
public MagicManaCost modCost(final MagicCard card, final MagicManaCost cost) {
|
||||
MagicManaCost currCost = cost;
|
||||
for (final MagicPermanentStatic mps : getStatics(MagicLayer.CostIncrease)) {
|
||||
currCost = mps.getStatic().increaseCost(mps.getPermanent(), card, cost);
|
||||
}
|
||||
for (final MagicPermanentStatic mps : getStatics(MagicLayer.CostReduction)) {
|
||||
currCost = mps.getStatic().reduceCost(mps.getPermanent(), card, cost);
|
||||
}
|
||||
return currCost;
|
||||
}
|
||||
|
||||
public void apply(final MagicLayer layer) {
|
||||
switch (layer) {
|
||||
case Game:
|
||||
|
|
|
@ -346,6 +346,13 @@ public class MagicManaCost {
|
|||
final int[] reducedAmounts = Arrays.copyOf(amounts, amounts.length);
|
||||
final int idx = type.ordinal();
|
||||
reducedAmounts[idx] -= Math.min(amounts[idx], amt);
|
||||
return MagicManaCost.create(getCanonicalText(reducedAmounts, 0));
|
||||
return MagicManaCost.create(getCanonicalText(reducedAmounts, XCount));
|
||||
}
|
||||
|
||||
public MagicManaCost increase(final MagicCostManaType type, final int amt) {
|
||||
final int[] reducedAmounts = Arrays.copyOf(amounts, amounts.length);
|
||||
final int idx = type.ordinal();
|
||||
reducedAmounts[idx] += amt;
|
||||
return MagicManaCost.create(getCanonicalText(reducedAmounts, XCount));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import magic.model.MagicAbility;
|
|||
import magic.model.MagicGame;
|
||||
import magic.model.MagicPermanent;
|
||||
import magic.model.MagicPlayer;
|
||||
import magic.model.MagicCard;
|
||||
import magic.model.MagicManaCost;
|
||||
import magic.model.MagicPowerToughness;
|
||||
import magic.model.MagicSubType;
|
||||
|
||||
|
@ -50,4 +52,14 @@ public class MagicDummyModifier implements MagicModifier {
|
|||
public void modGame(final MagicPermanent source, final MagicGame game) {
|
||||
//leave game unchanged
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagicManaCost reduceCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost) {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagicManaCost increaseCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost) {
|
||||
return cost;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,7 @@ public enum MagicLayer {
|
|||
SwitchPT, //7e. switch p/t
|
||||
Player, //8. affect player, e.g. you have hexproof
|
||||
Game, //9. affect game rules, e.g. modify maximum hand size, creature is Indestructible
|
||||
CostIncrease,
|
||||
CostReduction,
|
||||
;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import magic.model.MagicAbility;
|
|||
import magic.model.MagicGame;
|
||||
import magic.model.MagicPermanent;
|
||||
import magic.model.MagicPlayer;
|
||||
import magic.model.MagicCard;
|
||||
import magic.model.MagicPowerToughness;
|
||||
import magic.model.MagicSubType;
|
||||
import magic.model.MagicManaCost;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -27,4 +29,8 @@ public interface MagicModifier {
|
|||
void modPlayer(final MagicPermanent source, final MagicPlayer player);
|
||||
|
||||
void modGame(final MagicPermanent source, final MagicGame game);
|
||||
|
||||
MagicManaCost reduceCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost);
|
||||
|
||||
MagicManaCost increaseCost(final MagicPermanent source, final MagicCard card, final MagicManaCost cost);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue