add ability 'You may have SN enter the battlefield as a copy of any <permanent> on the battlefield.'

master
melvinzhang 2017-07-19 20:53:33 +08:00
parent c4f22b39bb
commit ee465685ba
2 changed files with 41 additions and 0 deletions

View File

@ -790,6 +790,12 @@ public enum MagicAbility {
card.add(new EntersTappedUnlessTrigger(MagicConditionFactory.Unless(condition)));
}
},
EntersAsCopy("You may have SN enter the battlefield as a copy of any " + ARG.WORDRUN + " on the battlefield\\.", 0) {
@Override
protected void addAbilityImpl(final MagicAbilityStore card, final Matcher arg) {
card.add(MagicETBEvent.copyOf(ARG.wordrun(arg)));
}
},
WhenMonstrous("When SN becomes monstrous, " + ARG.EFFECT, 0) {
@Override
protected void addAbilityImpl(final MagicAbilityStore card, final Matcher arg) {

View File

@ -1,7 +1,15 @@
package magic.model.event;
import magic.model.MagicGame;
import magic.model.MagicPayedCost;
import magic.model.MagicCardDefinition;
import magic.model.MagicChangeCardDefinition;
import magic.model.stack.MagicCardOnStack;
import magic.model.target.MagicCopyPermanentPicker;
import magic.model.choice.MagicTargetChoice;
import magic.model.choice.MagicMayChoice;
import magic.model.action.EnterAsCopyAction;
import magic.model.action.PlayCardFromStackAction;
public abstract class MagicETBEvent implements MagicCardEvent,MagicEventAction,MagicChangeCardDefinition {
@ -10,4 +18,31 @@ public abstract class MagicETBEvent implements MagicCardEvent,MagicEventAction,M
cdef.setEvent(this);
}
public static MagicETBEvent copyOf(final String desc) {
final MagicTargetChoice choice = new MagicTargetChoice("a " + desc);
return new MagicETBEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
new MagicMayChoice(choice),
MagicCopyPermanentPicker.create(),
this,
"PN may$ have SN enter the battlefield as a copy of any " + desc + "$ on the battlefield."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()) {
game.doAction(new EnterAsCopyAction(event.getCardOnStack(), event.getTarget()));
} else {
game.logAppendMessage(event.getPlayer(), "Put ${event.getCardOnStack()} onto the battlefield.");
game.doAction(new PlayCardFromStackAction(
event.getCardOnStack()
));
}
}
};
}
}