Implementing Channel
Posted: 02 Jul 2014, 17:27
I've begun working with the Channel ability word, starting with a simple card first, and have noticed something strange with the AI. Whichever AI I use, it always Channels as soon as it is possible, regardless of whether there's any valid target or not.
The main structure is pretty close to a Cycle activation, but can't work out why the AI's all excited about it...
The main structure is pretty close to a Cycle activation, but can't work out why the AI's all excited about it...
- Code: Select all
name=Shinen of Flight's Wings
image=http://mtgimage.com/card/shinen%20of%20flight%27s%20wings.jpg
value=2.500
rarity=C
type=Creature
subtype=Spirit
cost={4}{U}
pt=3/3
ability=Flying
timing=main
requires_groovy_code
oracle=Flying. Channel — {U}, Discard Shinen of Flight's Wings: Target creature gains flying until end of turn.
- Code: Select all
[
new MagicCardActivation(
[MagicCondition.HAND_CONDITION],
new MagicActivationHints(MagicTiming.Pump),
"Channel"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicCard source) {
return [
new MagicPayManaCostEvent(source, "{U}"),
new MagicDiscardSelfEvent(source)
];
}
@Override
public MagicEvent getEvent(final MagicSource source) {
return new MagicEvent(
source,
MagicTargetChoice.POS_TARGET_CREATURE,
MagicFlyingTargetPicker.create(),
this,
"Target creature\$ gains flying until end of turn."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPermanent(game,{
final MagicPermanent creature ->
game.doAction(new MagicGainAbilityAction(creature,MagicAbility.Flying));
});
}
}
]