added reinforce mechanic to the engine
parent
074a1043f8
commit
7bf3a10aba
|
@ -17,6 +17,7 @@ import magic.model.event.MagicTiming;
|
|||
import magic.model.event.MagicVividManaActivation;
|
||||
import magic.model.event.MagicPermanentActivation;
|
||||
import magic.model.event.MagicCyclingActivation;
|
||||
import magic.model.event.MagicReinforceActivation;
|
||||
import magic.model.mstatic.MagicCDA;
|
||||
import magic.model.mstatic.MagicStatic;
|
||||
import magic.model.trigger.MagicAllyGrowTrigger;
|
||||
|
@ -716,6 +717,14 @@ public enum MagicAbility {
|
|||
card.add(new MagicCyclingActivation(manaCost));
|
||||
}
|
||||
},
|
||||
Reinforce("reinforce", 20) {
|
||||
public void addAbilityImpl(final MagicCardDefinition card, final String arg) {
|
||||
final String[] token = arg.split(" ");
|
||||
final int n = Integer.parseInt(token[0]);
|
||||
final MagicManaCost manaCost = MagicManaCost.create(token[1]);
|
||||
card.add(new MagicReinforceActivation(n, manaCost));
|
||||
}
|
||||
},
|
||||
None("",0);
|
||||
|
||||
public static final Set<MagicAbility> CORE = EnumSet.range(AttacksEachTurnIfAble, Flanking);
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package magic.model.event;
|
||||
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicSource;
|
||||
import magic.model.MagicPayedCost;
|
||||
import magic.model.MagicPermanent;
|
||||
import magic.model.MagicCounterType;
|
||||
import magic.model.action.MagicChangeCountersAction;
|
||||
import magic.model.action.MagicPermanentAction;
|
||||
import magic.model.choice.MagicTargetChoice;
|
||||
import magic.model.event.MagicEvent;
|
||||
import magic.model.event.MagicSpellCardEvent;
|
||||
import magic.model.stack.MagicCardOnStack;
|
||||
import magic.model.target.MagicPumpTargetPicker;
|
||||
|
||||
public class MagicPutCounterEvent extends MagicEvent {
|
||||
|
||||
public MagicPutCounterEvent(final MagicSource source, final int amount) {
|
||||
super(
|
||||
source,
|
||||
MagicTargetChoice.POS_TARGET_CREATURE,
|
||||
MagicPumpTargetPicker.create(),
|
||||
amount,
|
||||
EA,
|
||||
"PN puts " + amount + " +1/+1 counters on target creature$."
|
||||
);
|
||||
}
|
||||
|
||||
private static final MagicEventAction EA = new MagicEventAction() {
|
||||
@Override
|
||||
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] choiceResults) {
|
||||
event.processTargetPermanent(game,choiceResults,0,new MagicPermanentAction() {
|
||||
public void doAction(final MagicPermanent creature) {
|
||||
game.doAction(new MagicChangeCountersAction(
|
||||
creature,
|
||||
MagicCounterType.PlusOne,
|
||||
event.getRefInt(),
|
||||
true
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package magic.model.event;
|
||||
|
||||
import magic.model.MagicCard;
|
||||
import magic.model.MagicCardDefinition;
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicLocationType;
|
||||
import magic.model.MagicManaCost;
|
||||
import magic.model.MagicPayedCost;
|
||||
import magic.model.MagicSource;
|
||||
import magic.model.action.MagicDrawAction;
|
||||
import magic.model.action.MagicPutItemOnStackAction;
|
||||
import magic.model.choice.MagicTargetChoice;
|
||||
import magic.model.condition.MagicCondition;
|
||||
import magic.model.stack.MagicCardOnStack;
|
||||
import magic.model.stack.MagicAbilityOnStack;
|
||||
|
||||
public class MagicReinforceActivation extends MagicCardActivation {
|
||||
|
||||
final MagicManaCost cost;
|
||||
final int amount;
|
||||
|
||||
public MagicReinforceActivation(final int n, final MagicManaCost aCost) {
|
||||
super(
|
||||
new MagicCondition[]{
|
||||
aCost.getCondition()
|
||||
},
|
||||
new MagicActivationHints(MagicTiming.Pump,true),
|
||||
"Reinforce"
|
||||
);
|
||||
cost = aCost;
|
||||
amount = n;
|
||||
}
|
||||
|
||||
public MagicEvent[] getCostEvent(final MagicCard source) {
|
||||
return new MagicEvent[]{
|
||||
new MagicPayManaCostEvent(
|
||||
source,
|
||||
source.getController(),
|
||||
cost
|
||||
),
|
||||
new MagicDiscardCardEvent(
|
||||
source,
|
||||
source.getController(),
|
||||
source
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagicEvent getEvent(final MagicSource source) {
|
||||
return new MagicEvent(
|
||||
source,
|
||||
this,
|
||||
"Reinforce."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] choices) {
|
||||
final MagicAbilityOnStack abilityOnStack = new MagicAbilityOnStack(
|
||||
this,
|
||||
new MagicPutCounterEvent(event.getSource(), amount),
|
||||
game.getPayedCost()
|
||||
);
|
||||
game.doAction(new MagicPutItemOnStackAction(abilityOnStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
final MagicTargetChoice getTargetChoice(final MagicCard source) {
|
||||
return MagicTargetChoice.POS_TARGET_CREATURE;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue