java code for Ward Sliver
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
java code for Ward Sliver
by kdesmond » 20 Sep 2012, 02:36
I'm trying to create java code for the card "Ward Sliver" and I am having some issues. The following is what I have so far:
If anyone has some suggestions I would be glad to hear. I have been stubbornly trying to resolve this myself but I am not a java programmer and I've reached the limit of what I can figure out quickly by looking at scripts for other cards. Thanks!!
- Code: Select all
public class Ward_Sliver {
public static final MagicWhenComesIntoPlayTrigger T = new MagicWhenComesIntoPlayTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer player) {
return new MagicEvent(
permanent,
player,
new MagicMayChoice(
"Choose a color",
MagicColorChoice.ALL_INSTANCE),
new Object[]{player},
this,
"You may$ Choose a color$." +
" All Slivers have protection from chosen color.");
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object[] choiceResults) {
//final MagicColor color=(MagicColor)choiceResults[1];
//MagicAbility ability = color.getProtectionAbility();
//final long givenAbilityFlags = ability.getMask();
};
};
/* public static MagicStatic genABStatic(final long givenAbilityFlags) {
return new MagicStatic(MagicLayer.Ability, MagicTargetFilter.TARGET_SLIVER) {
@Override
public long getAbilityFlags(
final MagicPermanent source,
final MagicPermanent permanent,
final long flags) {
return flags | givenAbilityFlags;
//return flags | MagicAbility.ProtectionFromRed.getMask();
}
};
}*/
public static final MagicStatic S = new MagicStatic(
MagicLayer.Ability,
MagicTargetFilter.TARGET_SLIVER) {
@Override
public long getAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final long flags) {
//return flags | ability.getMask();
return flags | MagicAbility.ProtectionFromRed.getMask();
}
};
};
If anyone has some suggestions I would be glad to hear. I have been stubbornly trying to resolve this myself but I am not a java programmer and I've reached the limit of what I can figure out quickly by looking at scripts for other cards. Thanks!!
Re: java code for Ward Sliver
by melvin » 20 Sep 2012, 05:19
Hi kdesmond, welcome to the forum and to Magarena modifications
The solution in this case is to create the MagicStatic object and add it to the game as part of the resolution of the trigger. See src/magic/card/Aven_Mimeomancer.java.
The executeEvent for the trigger should look something like the following:
The solution in this case is to create the MagicStatic object and add it to the game as part of the resolution of the trigger. See src/magic/card/Aven_Mimeomancer.java.
The executeEvent for the trigger should look something like the following:
- Code: Select all
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final MagicColor color=(MagicColor)choiceResults[1];
MagicAbility protection = color.getProtectionAbility();
game.doAction(new MagicAddStaticAction((MagicPermanent)event.getSource(), new MagicStatic(
MagicLayer.Ability,
MagicTargetFilter.TARGET_SLIVER) {
@Override
public long getAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final long flags) {
return flags | protection.getMask();
}
));
};
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: java code for Ward Sliver
by kdesmond » 21 Sep 2012, 01:09
This worked like a charm, thank you!
Now I just have to remove the "may" part from the colour choice, and it should be ready to submit.
Now I just have to remove the "may" part from the colour choice, and it should be ready to submit.
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 52 guests