Adding new cards with Groovy
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Adding new cards with Groovy
by hong yie » 08 Sep 2013, 14:30
trying to script captivating vampire, catapult master, supreme inquisitor & friends...hong yie wrote:do we have someway to apply "tap an untapped ... creature" to pay a cost of ability before? i see many interesting cards use this "tap" to pay a cost of its ability.
Not possible at the moment but doable. Any specific card you are looking at?

vampire hounds looks interesting, can at this card along with zombie infestation fill graveyard. including the spellshapers, these creatures require discard as cost of their abilities.hong yie wrote:how to script "discard a creature card:..." as a cost of an ability? filter?
Not possible at the moment but doable. Any specific card you are looking at?

-
hong yie - Programmer
- Posts: 216
- Joined: 10 Mar 2013, 06:44
- Location: Jakarta
- Has thanked: 75 times
- Been thanked: 9 times
Re: Adding new cards with Groovy
by melvin » 15 Sep 2013, 09:16

Magarena/scripts/Dismiss_into_Dream.txt
- Code: Select all
name=Dismiss into Dream
url=http://magiccards.info/m14/en/50.html
image=http://magiccards.info/scans/en/m14/50.jpg
value=4.398
rarity=R
type=Enchantment
cost={6}{U}
ability=lord creatures your opponents control have sac when targeted
static=opponent
timing=enchantment
requires_groovy_code
- Code: Select all
[
new MagicStatic(
MagicLayer.Type,
MagicTargetFilter.TARGET_CREATURE_YOUR_OPPONENT_CONTROLS
) {
@Override
public void modSubTypeFlags(final MagicPermanent permanent, final Set<MagicSubType> flags) {
flags.add(MagicSubType.Illusion);
}
}
]
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Adding new cards with Groovy
by hong yie » 19 Sep 2013, 21:05

Broodmother Dragon.txt
- Code: Select all
name=Broodmother Dragon
url=http://magiccards.info/arb/en/53.html
image=http://magiccards.info/scans/en/arb/53.jpg
value=4.167
rarity=M
type=Creature
subtype=Dragon
cost={2}{R}{R}{R}{G}
pt=4/4
ability=flying
timing=main
requires_groovy_code
- Code: Select all
[
new MagicAtUpkeepTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
return new MagicEvent(
permanent,
this,
"PN puts a 1/1 red and green Dragon creature token with flying and devour 2 onto the battlefield."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicPlayTokenAction(event.getPlayer(),TokenCardDefinitions.get("Dragon1")));
}
}
]

- Code: Select all
name=Dragon1
token=Dragon
image=http://magiccards.info/extras/token/alara-reborn/dragon.jpg
value=4
type=Creature
subtype=Dragon
color=rg
cost={0}
pt=1/1
ability=flying
requires_groovy_code=Marrow Chomper

Last edited by hong yie on 20 Sep 2013, 07:42, edited 1 time in total.
-
hong yie - Programmer
- Posts: 216
- Joined: 10 Mar 2013, 06:44
- Location: Jakarta
- Has thanked: 75 times
- Been thanked: 9 times
Re: Adding new cards with Groovy
by ember hauler » 20 Sep 2013, 06:27
Cool!
Broodmother Dragon is Mythic Rare, though.
I'm not sure if it's significant for the AI engine.
Broodmother Dragon is Mythic Rare, though.
I'm not sure if it's significant for the AI engine.
- ember hauler
- Posts: 79
- Joined: 14 Aug 2013, 08:13
- Has thanked: 27 times
- Been thanked: 14 times
Re: Adding new cards with Groovy
by melvin » 20 Sep 2013, 13:06
@hong yie: Thanks for Dragon Broodmother and Ivory Mask (via firemind.ch). I've included them in the upcoming release.
@ember hauler: Rarity is mainly for the deck generation, it also counts towards a cards score which is used for AI's card evaluation.
@ember hauler: Rarity is mainly for the deck generation, it also counts towards a cards score which is used for AI's card evaluation.
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Adding new cards with Groovy
by jerichopumpkin » 20 Sep 2013, 13:42
I'm trying to add Dormant Sliver, but the ability 'all slivers gain "When this creature enters play, you draw a card"' does not work.
Anyone can tell what I'm doing wrong?
P.S. I've also tried to do it with groovy, with the same result
P.P.S I had to remove urls from the code, else the forum won't let me post
- Code: Select all
name=Dormant Sliver
url=*
image=*
value=3.425
rarity=U
type=Creature
subtype=Sliver
cost={2}{U}{G}
pt=2/2
ability=lord all sliver creatures have defender;lord all sliver creatures have enters draw card 1
static=all
timing=main
Anyone can tell what I'm doing wrong?
P.S. I've also tried to do it with groovy, with the same result
P.P.S I had to remove urls from the code, else the forum won't let me post
- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Re: Adding new cards with Groovy
by Huggybaby » 20 Sep 2013, 14:06
You can post urls after five posts.
-
Huggybaby - Administrator
- Posts: 3226
- Joined: 15 Jan 2006, 19:44
- Location: Finally out of Atlanta
- Has thanked: 742 times
- Been thanked: 601 times
Re: Adding new cards with Groovy
by melvin » 20 Sep 2013, 14:11
@jerichopumpkin This is a known limitation of the current system of granting abilities, ETB effects do not work. We'll work on supporting this for the next release.
Update 1: removed this limitation as of https://code.google.com/p/magarena/sour ... 8ee41ca111
Update 2: Included Dormant Sliver for the next release in https://code.google.com/p/magarena/sour ... a7db6cc06b Thanks for this card
Update 1: removed this limitation as of https://code.google.com/p/magarena/sour ... 8ee41ca111
Update 2: Included Dormant Sliver for the next release in https://code.google.com/p/magarena/sour ... a7db6cc06b Thanks for this card

-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Adding new cards with Groovy
by jerichopumpkin » 20 Sep 2013, 14:43
woah! so fast!
I'm working on a lot of slivers, I'll send them through ProjectFiremind as soon I'm done testing.
Hope I will make it for this month release!
edit: Well, I've submitted the cards I've tested so far.
But now I've found a wall: Cautery Sliver.
Problem is how do you implemnt the custom filter for "target Sliver creature or player"?
Also a hint on Ghostflame Sliver would be appreciated

I'm working on a lot of slivers, I'll send them through ProjectFiremind as soon I'm done testing.
Hope I will make it for this month release!
edit: Well, I've submitted the cards I've tested so far.
But now I've found a wall: Cautery Sliver.
Problem is how do you implemnt the custom filter for "target Sliver creature or player"?
Also a hint on Ghostflame Sliver would be appreciated

- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Re: Adding new cards with Groovy
by melvin » 21 Sep 2013, 01:54
Cautery Sliver needs to define a new filter before the list of abilities [...] using def, something like
- Code: Select all
def SLIVER_CREATURE_OR_PLAYER = new MagicTargetFilterImpl() {
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicTarget target) {
return target.isPlayer() || (target.isCreature() && target.hasSubType(MagicSubType.Sliver));
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Permanent ||
targetType==MagicTargetType.Player;
}
};
[
// abilities
]
- Code: Select all
[
new MagicStatic(
MagicLayer.Color,
MagicTargetFilter.TARGET_SLIVER
) {
@Override
public int getColorFlags(final MagicPermanent permanent, final int flags) {
return 0;
}
}
]
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Adding new cards with Groovy
by melvin » 21 Sep 2013, 10:28

Magarena/scripts/Obzedat_s_Aid.txt
- Code: Select all
name=Obzedat's Aid
url=http://magiccards.info/dgm/en/89.html
image=http://magiccards.info/scans/en/dgm/89.jpg
value=4.644
rarity=R
type=Sorcery
cost={3}{W}{B}
timing=main
requires_groovy_code
- Code: Select all
[
new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
MagicTargetChoice.TARGET_PERMANENT_CARD_FROM_GRAVEYARD,
MagicGraveyardTargetPicker.PutOntoBattlefield,
this,
"Return target permanent card\$ from your graveyard to the battlefield."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetCard(game,new MagicCardAction() {
public void doAction(final MagicCard targetCard) {
game.doAction(new MagicReanimateAction(
targetCard,
event.getPlayer()
));
}
});
}
}
]
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Adding new cards with Groovy
by jerichopumpkin » 21 Sep 2013, 19:23
still having trouble with Cautery Sliver, it causes Magarena to crash.
here is th groovy code:
CRASH REPORT FOR MAGARENA THREAD Thread[AWT-EventQueue-0,6,main]
CREATED ON 2013/09/21 21:20:18
MAGARENA VERSION 1.41, JRE 1.7.0_25, OS Windows 7_6.1 x86
Turn : 1 Phase : Mulligan Step : Begin Player : Computer Score : 0
0] Player : Jericho Life : 20 Delayed : Total=0
1] Player : Computer Life : 20 Delayed : Total=0
Stack : 0
Score = 0
Exception from controller.runGame: startup failed:
C:\Users\Torre\Desktop\Magarena-1.41\Magarena\scripts\Cautery_Sliver.groovy: 61: [Static type checking] - Cannot find matching method magic.model.event.MagicEvent#<init>(magic.model.MagicPermanent, Cautery_Sliver$1, magic.model.target.MagicPreventTargetPicker, Cautery_Sliver$4, java.lang.String). Please check if the declared type is right and if the method exists.
@ line 61, column 20.
return new MagicEvent(
^
1 error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\Users\Torre\Desktop\Magarena-1.41\Magarena\scripts\Cautery_Sliver.groovy: 61: [Static type checking] - Cannot find matching method magic.model.event.MagicEvent#<init>(magic.model.MagicPermanent, Cautery_Sliver$1, magic.model.target.MagicPreventTargetPicker, Cautery_Sliver$4, java.lang.String). Please check if the declared type is right and if the method exists.
@ line 61, column 20.
return new MagicEvent(
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1063)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:516)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:565)
at magic.data.CardDefinitions.addCardSpecificGroovyCode(CardDefinitions.java:120)
at magic.data.CardProperty$30.setProperty(CardProperty.java:182)
at magic.model.MagicCardDefinition.loadScript(MagicCardDefinition.java:125)
at magic.model.MagicCard.<init>(MagicCard.java:46)
at magic.model.MagicCard.<init>(MagicCard.java:38)
at magic.model.MagicPlayer.createHandAndLibrary(MagicPlayer.java:296)
at magic.model.MagicDuel.nextGame(MagicDuel.java:198)
at magic.ui.MagicFrame.nextGame(MagicFrame.java:550)
at magic.ui.DuelPanel.actionPerformed(DuelPanel.java:357)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
here is th groovy code:
- Code: Select all
def SLIVER_CREATURE_OR_PLAYER = new MagicTargetFilterImpl() {
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicTarget target) {
return target.isPlayer() || (target.isCreature() && target.hasSubType(MagicSubType.Sliver));
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Permanent ||
targetType==MagicTargetType.Player;
}
};
def CauteryDamage = new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"CauteryDam"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{1}"),
new MagicSacrificeEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE_OR_PLAYER,
new MagicDamageTargetPicker(1),
this,
"SN deals 1 damage to target creature or player\$."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
final MagicDamage damage=new MagicDamage(event.getSource(),target,1);
game.doAction(new MagicDealDamageAction(damage));
}
});
}
};
def CauteryPrevent = new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Pump),
"CauteryPrev"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{1}"),
new MagicSacrificeEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
SLIVER_CREATURE_OR_PLAYER,
MagicPreventTargetPicker.getInstance(),
this,
"Prevent the next 1 damage that would be dealt to target sliver creature\$ or player\$ this turn."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
game.doAction(new MagicPreventDamageAction(target,1));
}
});
}
};
[
new MagicStatic(
MagicLayer.Ability,
MagicTargetFilter.TARGET_SLIVER
) {
@Override
public void modAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final Set<MagicAbility> flags) {
permanent.addAbility(CauteryDamage);
permanent.addAbility(CauteryPrevent);
}
}
]
CRASH REPORT FOR MAGARENA THREAD Thread[AWT-EventQueue-0,6,main]
CREATED ON 2013/09/21 21:20:18
MAGARENA VERSION 1.41, JRE 1.7.0_25, OS Windows 7_6.1 x86
Turn : 1 Phase : Mulligan Step : Begin Player : Computer Score : 0
0] Player : Jericho Life : 20 Delayed : Total=0
1] Player : Computer Life : 20 Delayed : Total=0
Stack : 0
Score = 0
Exception from controller.runGame: startup failed:
C:\Users\Torre\Desktop\Magarena-1.41\Magarena\scripts\Cautery_Sliver.groovy: 61: [Static type checking] - Cannot find matching method magic.model.event.MagicEvent#<init>(magic.model.MagicPermanent, Cautery_Sliver$1, magic.model.target.MagicPreventTargetPicker, Cautery_Sliver$4, java.lang.String). Please check if the declared type is right and if the method exists.
@ line 61, column 20.
return new MagicEvent(
^
1 error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\Users\Torre\Desktop\Magarena-1.41\Magarena\scripts\Cautery_Sliver.groovy: 61: [Static type checking] - Cannot find matching method magic.model.event.MagicEvent#<init>(magic.model.MagicPermanent, Cautery_Sliver$1, magic.model.target.MagicPreventTargetPicker, Cautery_Sliver$4, java.lang.String). Please check if the declared type is right and if the method exists.
@ line 61, column 20.
return new MagicEvent(
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1063)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:516)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:565)
at magic.data.CardDefinitions.addCardSpecificGroovyCode(CardDefinitions.java:120)
at magic.data.CardProperty$30.setProperty(CardProperty.java:182)
at magic.model.MagicCardDefinition.loadScript(MagicCardDefinition.java:125)
at magic.model.MagicCard.<init>(MagicCard.java:46)
at magic.model.MagicCard.<init>(MagicCard.java:38)
at magic.model.MagicPlayer.createHandAndLibrary(MagicPlayer.java:296)
at magic.model.MagicDuel.nextGame(MagicDuel.java:198)
at magic.ui.MagicFrame.nextGame(MagicFrame.java:550)
at magic.ui.DuelPanel.actionPerformed(DuelPanel.java:357)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Re: Adding new cards with Groovy
by melvin » 22 Sep 2013, 01:01
Sorry about that, forgot to mention that you need to create the choice as well. Here is the completed card which I've added. It is based on updated syntax for 1.42 so it may not work in 1.41.

Magarena/scripts/Cautery_Sliver.txt

Magarena/scripts/Cautery_Sliver.txt
- Code: Select all
name=Cautery Sliver
url=http://magiccards.info/pc/en/154.html
image=http://magiccards.info/scans/en/pc/154.jpg
value=3.425
rarity=U
type=Creature
subtype=Sliver
cost={R}{W}
pt=2/2
static=all
timing=main
requires_groovy_code
- Code: Select all
def SLIVER_CREATURE_OR_PLAYER = new MagicTargetFilterImpl() {
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicTarget target) {
return target.isPlayer() || (target.isCreature() && target.hasSubType(MagicSubType.Sliver));
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Permanent ||
targetType==MagicTargetType.Player;
}
};
def POS_TARGET_SLIVER_CREATURE_OR_PLAYER = new MagicTargetChoice(
SLIVER_CREATURE_OR_PLAYER,
MagicTargetHint.Positive,
"target Sliver creature or player"
)
def CauteryDamage = new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{1}"),
new MagicSacrificeEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE_OR_PLAYER,
new MagicDamageTargetPicker(1),
this,
"SN deals 1 damage to target creature or player\$."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
final MagicDamage damage=new MagicDamage(event.getSource(),target,1);
game.doAction(new MagicDealDamageAction(damage));
}
});
}
};
def CauteryPrevent = new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Pump),
"Prevent"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{1}"),
new MagicSacrificeEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
POS_TARGET_SLIVER_CREATURE_OR_PLAYER,
MagicPreventTargetPicker.getInstance(),
this,
"Prevent the next 1 damage that would be dealt to target Sliver creature or player\$ this turn."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
game.doAction(new MagicPreventDamageAction(target,1));
}
});
}
};
[
new MagicStatic(
MagicLayer.Ability,
MagicTargetFilter.TARGET_SLIVER
) {
@Override
public void modAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final Set<MagicAbility> flags) {
permanent.addAbility(CauteryDamage);
permanent.addAbility(CauteryPrevent);
}
}
]
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Adding new cards with Groovy
by jerichopumpkin » 22 Sep 2013, 01:34
Oh, I see now. Well, since the card is ready, I'll just wait for the next release to use it.
Thank you very much, I learned another piece of groovy.
Thank you very much, I learned another piece of groovy.
- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Re: Adding new cards with Groovy
by ember hauler » 23 Sep 2013, 16:41
Trying to submit a new card to Project Firemind, but it returns Error 500 for some reason.
So I'll post it here. It's from the Theros:

So I'll post it here. It's from the Theros:

- Code: Select all
name=Anger of the Gods
url=http://magiccards.info/ths/en/112.html
image=http://magiccards.info/scans/en/ths/112.jpg
value=4.581
removal=3
rarity=R
type=Sorcery
cost={1}{R}{R}
timing=removal
requires_groovy_code
- Code: Select all
[
new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
this,
"SN deals 3 damage to target creature or player\$. " +
"If a creature dealt damage this way would die this turn, exile it instead."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
final int amount=3;
final Collection<MagicPermanent> targets=
game.filterPermanents(event.getPlayer(),MagicTargetFilter.TARGET_CREATURE);
for (final MagicPermanent target : targets) {
final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
game.doAction(new MagicDealDamageAction(damage));
if (target.isCreature()) {
game.doAction(new MagicAddTurnTriggerAction(
(MagicPermanent)target,
MagicWhenLeavesPlayTrigger.IfDieExileInstead
));
}
}
}
}
]
- ember hauler
- Posts: 79
- Joined: 14 Aug 2013, 08:13
- Has thanked: 27 times
- Been thanked: 14 times
Who is online
Users browsing this forum: No registered users and 2 guests