added monstrosity <n> <mana cost> to ability property

master
melvin 2013-10-06 10:22:44 +08:00
parent b16f6f9219
commit 3a12aabe5e
4 changed files with 84 additions and 8 deletions

View File

@ -24,6 +24,7 @@ import magic.model.event.MagicNinjutsuActivation;
import magic.model.event.MagicEvokeActivation;
import magic.model.event.MagicKickerCost;
import magic.model.event.MagicMultikickerCost;
import magic.model.event.MagicMonstrosityActivation;
import magic.model.mstatic.MagicCDA;
import magic.model.mstatic.MagicStatic;
import magic.model.trigger.MagicAllyGrowTrigger;
@ -816,6 +817,14 @@ public enum MagicAbility {
card.add(MagicWhenDamageIsDealtTrigger.Poisonous(n));
}
},
Monstrosity("monstrosity", 10) {
protected void addAbilityImpl(final MagicAbilityStore 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 MagicMonstrosityActivation(manaCost, n));
}
},
None("",0);
public static final Set<MagicAbility> PROTECTION_FLAGS = EnumSet.range(ProtectionFromBlack, ProtectionFromZombies);

View File

@ -15,17 +15,21 @@ public enum MagicPermanentState {
Destroyed("destroyed",""),
CannotAttack("can't attack",""),
NoCombatDamage("assigns no combat damage",""),
MustPayEchoCost("",""),
PreventAllDamage("prevent all damage that would be dealt this turn","")
MustPayEchoCost("echo",""),
PreventAllDamage("prevent all damage that would be dealt this turn",""),
Monstrous("monstrous", "")
;
// states that persist after cleanup
public static final int CLEANUP_MASK =
Tapped.getMask()|
Summoned.getMask()|
DoesNotUntapDuringNext.getMask()|
ExcludeManaSource.getMask()|
ExcludeFromCombat.getMask()|
MustPayEchoCost.getMask();
Tapped.getMask()
| Summoned.getMask()
| DoesNotUntapDuringNext.getMask()
| ExcludeManaSource.getMask()
| ExcludeFromCombat.getMask()
| MustPayEchoCost.getMask()
| Monstrous.getMask()
;
private final String description;
private final String text;

View File

@ -9,6 +9,7 @@ import magic.model.MagicCounterType;
import magic.model.MagicGame;
import magic.model.MagicPlayer;
import magic.model.MagicPermanent;
import magic.model.MagicPermanentState;
import magic.model.MagicSource;
import magic.model.MagicSubType;
import magic.model.MagicType;
@ -56,6 +57,13 @@ public interface MagicCondition {
return game.canPlaySorcery(source.getController()) == false;
}
};
MagicCondition NOT_MONSTROUS_CONDITION=new MagicCondition() {
public boolean accept(final MagicSource source) {
final MagicPermanent permanent=(MagicPermanent)source;
return permanent.hasState(MagicPermanentState.Monstrous) == false;
}
};
MagicCondition SORCERY_CONDITION=new MagicCondition() {
public boolean accept(final MagicSource source) {

View File

@ -0,0 +1,55 @@
package magic.model.event;
import magic.model.MagicGame;
import magic.model.MagicManaCost;
import magic.model.MagicPayedCost;
import magic.model.MagicPermanent;
import magic.model.MagicPermanentState;
import magic.model.MagicCounterType;
import magic.model.action.MagicChangeCountersAction;
import magic.model.action.MagicChangeStateAction;
import magic.model.condition.MagicCondition;
import java.util.Arrays;
public class MagicMonstrosityActivation extends MagicPermanentActivation {
private static final MagicActivationHints HINT = new MagicActivationHints(MagicTiming.Pump);
private static final MagicCondition COND[] = new MagicCondition[]{ MagicCondition.NOT_MONSTROUS_CONDITION };
private final MagicManaCost cost;
private final int n;
public MagicMonstrosityActivation(final MagicManaCost aCost,final int aN) {
super(COND, HINT, "Monstrosity");
cost = aCost;
n = aN;
}
@Override
public Iterable<? extends MagicEvent> getCostEvent(final MagicPermanent source) {
return Arrays.asList(new MagicPayManaCostEvent(source,cost));
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
this,
"If SN isn't monstrous, put " + n + " +1/+1 counter on it and it becomes monstrous."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicChangeCountersAction(
event.getPermanent(),
MagicCounterType.PlusOne,
n,
true
));
game.doAction(MagicChangeStateAction.Set(
event.getPermanent(),
MagicPermanentState.Monstrous
));
}
}