convert from java code to groovy code

master
melvin 2013-05-27 13:24:16 +08:00
parent 5ca4fa817e
commit c8b894c999
3 changed files with 31 additions and 49 deletions

View File

@ -0,0 +1,30 @@
[
new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
new MagicBuybackChoice(
MagicTargetChoice.NEG_TARGET_CREATURE,
MagicManaCost.create("{3}")
),
new MagicNoCombatTargetPicker(true,false,false),
this,
"Target creature\$ can't attack this turn. " +
"If the buyback cost was payed\$, return SN to its owner's hand as it resolves."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
game.doAction(new MagicChangeStateAction(creature,MagicPermanentState.CannotAttack,true));
if (event.isBuyback()) {
game.doAction(new MagicChangeCardDestinationAction(event.getCardOnStack(), MagicLocationType.OwnersHand));
}
}
});
}
}
]

View File

@ -6,4 +6,4 @@ rarity=C
type=Instant
cost={W}
timing=mustattack
requires_card_code
requires_groovy_code

View File

@ -1,48 +0,0 @@
package magic.card;
import magic.model.MagicGame;
import magic.model.MagicLocationType;
import magic.model.MagicManaCost;
import magic.model.MagicPayedCost;
import magic.model.MagicPermanent;
import magic.model.MagicPermanentState;
import magic.model.action.MagicChangeCardDestinationAction;
import magic.model.action.MagicChangeStateAction;
import magic.model.action.MagicPermanentAction;
import magic.model.choice.MagicBuybackChoice;
import magic.model.choice.MagicTargetChoice;
import magic.model.event.MagicEvent;
import magic.model.event.MagicSpellCardEvent;
import magic.model.stack.MagicCardOnStack;
import magic.model.target.MagicNoCombatTargetPicker;
public class Change_of_Heart {
public static final MagicSpellCardEvent E = new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
new MagicBuybackChoice(
MagicTargetChoice.NEG_TARGET_CREATURE,
MagicManaCost.create("{3}")),
new MagicNoCombatTargetPicker(true,false,false),
this,
"Target creature$ can't attack this turn. " +
"If the buyback cost was payed$, return SN to its owner's hand as it resolves.");
}
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event) {
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
game.doAction(new MagicChangeStateAction(creature,MagicPermanentState.CannotAttack,true));
if (event.isBuyback()) {
game.doAction(new MagicChangeCardDestinationAction(event.getCardOnStack(), MagicLocationType.OwnersHand));
}
}
});
}
};
}