added 'evolve' mechanic to ability

master
melvin 2013-01-27 09:50:17 +08:00
parent c0489e5455
commit 991fc0ead5
2 changed files with 40 additions and 0 deletions

View File

@ -64,6 +64,7 @@ import magic.model.trigger.MagicSacrificeAtEnd;
import magic.model.trigger.MagicWhenDiesTrigger;
import magic.model.trigger.MagicAtEndOfTurnTrigger;
import magic.model.trigger.MagicAtUpkeepTrigger;
import magic.model.trigger.MagicWhenOtherComesIntoPlayTrigger;
import java.util.EnumSet;
import java.util.Set;
@ -695,6 +696,12 @@ public enum MagicAbility {
card.add(MagicPermanentActivation.SwitchPT(manaCost));
}
},
Evolve("evolve", 20) {
public void addAbilityImpl(final MagicCardDefinition card, final String arg) {
assert arg.isEmpty() : this + " does not accept arg = " + arg;
card.add(MagicWhenOtherComesIntoPlayTrigger.Evolve);
}
},
None("",0);
public static final Set<MagicAbility> CORE = EnumSet.range(AttacksEachTurnIfAble, Flanking);

View File

@ -1,6 +1,10 @@
package magic.model.trigger;
import magic.model.MagicPermanent;
import magic.model.MagicGame;
import magic.model.MagicCounterType;
import magic.model.event.MagicEvent;
import magic.model.action.MagicChangeCountersAction;
public abstract class MagicWhenOtherComesIntoPlayTrigger extends MagicTrigger<MagicPermanent> {
public MagicWhenOtherComesIntoPlayTrigger(final int priority) {
@ -12,4 +16,33 @@ public abstract class MagicWhenOtherComesIntoPlayTrigger extends MagicTrigger<Ma
public MagicTriggerType getType() {
return MagicTriggerType.WhenOtherComesIntoPlay;
}
public static final MagicWhenOtherComesIntoPlayTrigger Evolve = new MagicWhenOtherComesIntoPlayTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
final int power = otherPermanent.getPower();
return (permanent != otherPermanent &&
otherPermanent.isCreature() &&
permanent.isCreature() &&
(otherPermanent.getPower() > permanent.getPower() ||
otherPermanent.getToughness() > permanent.getToughness())) ?
new MagicEvent(
permanent,
this,
"PN put a +1/+1 counter on SN.") :
MagicEvent.NONE;
}
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object[] choiceResults) {
game.doAction(new MagicChangeCountersAction(
event.getPermanent(),
MagicCounterType.PlusOne,
1,
true
));
}
};
}