Adding new cards with Groovy
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Adding new cards with Groovy
by melvin » 20 Jul 2013, 04:10
This next creature is as large as the largest creature in Magarena 1.39.

Magarena/scripts/Emrakul__the_Aeons_Torn.txt

Magarena/scripts/Emrakul__the_Aeons_Torn.txt
- Code: Select all
name=Emrakul, the Aeons Torn
url=http://magiccards.info/roe/en/4.html
image=http://magiccards.info/scans/en/roe/4.jpg
value=3.708
rarity=M
type=Legendary,Creature
subtype=Eldrazi
cost={15}
pt=15/15
ability=can't be countered,\
flying,\
protection from colored spells,\
annihilator 6,\
dead recover graveyard
timing=main
requires_groovy_code
- Code: Select all
[
new MagicWhenSpellIsCastTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game, final MagicPermanent permanent, final MagicCardOnStack spell) {
return new MagicEvent(
spell,
this,
"PN takes an extra turn after this one."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicChangeExtraTurnsAction(event.getPlayer(),1));
}
}
]
-
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 » 21 Jul 2013, 06:52
Trying this code...

- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Life"
) {
@Override
public MagicEvent[] getCostEvent(final MagicPermanent source) {
final MagicTargetChoice targetChoice = new MagicTargetChoice(
MagicTargetFilter.Factory.tribal(MagicSubType.Cleric, MagicTargetFilter.Control.You),
false,
MagicTargetHint.None,
"a Cleric to sacrifice"
);
return [
new MagicTapEvent(source),
new MagicPayManaCostEvent(source,"{W}"),
new MagicSacrificePermanentEvent(source,targetChoice)
];
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
final int toughness=creature.getToughness();
game.doAction(new MagicSacrificeAction(creature));
game.doAction(new MagicChangeLifeAction(event.getPlayer(),toughness));
}
});
}
}
]
this is harder than i thought, time for more enlightenment.9: [Static type checking] - Cannot find matching method java.lang.Class#tribal(magic.model.MagicSubType, magic.model.target.MagicTargetFilter$Control). Please check if the declared type is right and if the method exists.
@ line 9, column 17.
MagicTargetFilter.Factory.tribal(MagicSubType.Cleric, MagicTargetFilter.Control.You),
8: [Static type checking] - Cannot find matching method magic.model.choice.MagicTargetChoice#<init>(java.lang.Object, boolean, magic.model.target.MagicTargetHint, java.lang.String). Please check if the declared type is right and if the method exists.
@ line 8, column 52.
icTargetChoice targetChoice = new MagicT

-
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 » 21 Jul 2013, 14:24
@hong yie: Did you update your version to https://buildhive.cloudbees.com/job/mel ... a-1.40.zip ? As mentioned, the Cabal Archon type code only works in the new version and not for 1.39. Also your script is missing the getPermanentEvent method.
-
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 » 22 Jul 2013, 00:54
surely, i haven't.@hong yie: Did you update your version to https://buildhive.cloudbees.com/job/mel ... a-1.40.zip ? As mentioned, the Cabal Archon type code only works in the new version and not for 1.39. Also your script is missing the getPermanentEvent method.
that explains the errors i got here. unrecognized methods.
will try again, after update to version 1.4. thank's.

-
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 hong yie » 22 Jul 2013, 15:07
updated to newest version source, and tried this code

- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Life"
) {
@Override
public MagicEvent[] getCostEvent(final MagicPermanent source) {
final MagicTargetChoice targetChoice = new MagicTargetChoice(
MagicTargetFilter.Factory.tribal(MagicSubType.Cleric, MagicTargetFilter.Control.You),
false,
MagicTargetHint.None,
"a Cleric to sacrifice"
);
return [
new MagicTapEvent(source),
new MagicPayManaCostEvent(source,"{W}"),
new MagicSacrificePermanentEvent(source,targetChoice)
];
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
final int toughness=creature.getToughness();
game.doAction(new MagicSacrificeAction(creature));
game.doAction(new MagicChangeLifeAction(event.getPlayer(),toughness));
}
});
}
}
]
still need learning, i see.Can't have an abstract method in a non-abstract class. The class 'starlit_sanctum$1' must be declared abstract or the method 'magic.model.event.MagicEvent getPermanentEvent(magic.model.MagicPermanent, magic.model.MagicPayedCost)' must be implemented.
@ line 5, column 4.

-
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 » 22 Jul 2013, 15:27
You are missing the getPermanentEvent method, this is the method which generates the event that goes on the stack. For example, in Cabal Archon, it has the following method:
- Code: Select all
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_PLAYER,
this,
"Target player\$ loses 2 life and PN gains 2 life."
);
}
-
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 » 22 Jul 2013, 15:35
Starlit Sanctum's ability is more complex as it uses the creature that was sacrificed in the effect, it does not actually target a creature. It should look something like the following:
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Life"
) {
@Override
public MagicEvent[] getCostEvent(final MagicPermanent source) {
final MagicTargetChoice targetChoice = new MagicTargetChoice(
MagicTargetFilter.Factory.tribal(MagicSubType.Cleric, MagicTargetFilter.Control.You),
false,
MagicTargetHint.None,
"a Cleric to sacrifice"
);
return [
new MagicTapEvent(source),
new MagicPayManaCostEvent(source,"{W}"),
new MagicSacrificePermanentEvent(source,targetChoice)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
payedCost.getTarget(),
this,
"PN gains life equal to RN's toughness."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicChangeLifeAction(
event.getPlayer(),
event.getRefPermanent().getToughness()
));
}
}
]
-
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 » 27 Jul 2013, 17:34

Argothian_Enchantress.txt
- Code: Select all
name=Argothian Enchantress
url=http://magiccards.info/us/en/234.html
image=http://magiccards.info/scans/en/us/234.jpg
value=4.617
rarity=R
type=Creature
subtype=Human,Druid
cost={1}{G}
pt=0/1
ability=shroud
timing=fmain
requires_groovy_code
- Code: Select all
[
new MagicWhenOtherSpellIsCastTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicCardOnStack spell) {
return (permanent.isFriend(spell) &&
spell.getCardDefinition().isEnchantment()) ?
new MagicEvent(
permanent,
this,
"PN draw a card."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicDrawAction(event.getPlayer()));
}
}
]
-
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 hong yie » 27 Jul 2013, 18:20

Enchantress_s_Presence.txt
- Code: Select all
name=Enchantress's Presence
url=http://magiccards.info/on/en/261.html
image=http://magiccards.info/scans/en/on/261.jpg
value=4.167
rarity=R
type=Enchantment
cost={2}{G}
timing=Enchantment
requires_groovy_code
- Code: Select all
[
new MagicWhenOtherSpellIsCastTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicCardOnStack spell) {
return (permanent.isFriend(spell) &&
spell.getCardDefinition().isEnchantment()) ?
new MagicEvent(
permanent,
this,
"PN draw a card."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicDrawAction(event.getPlayer()));
}
}
]
-
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 » 28 Jul 2013, 01:26
Thanks for both cards
I added Enchantress's Presence first as https://code.google.com/p/magarena/sour ... 2c2c7de929
Since Argothian Enchantress has the same triggered ability, we can avoid having duplicate groovy scripts by referring to Enchantress's Presence script using requires_groovy_code=Enchantress's Presence. So the simplified Argothian Enchantress only has the following Argothian_Enchantress.txt file:

Since Argothian Enchantress has the same triggered ability, we can avoid having duplicate groovy scripts by referring to Enchantress's Presence script using requires_groovy_code=Enchantress's Presence. So the simplified Argothian Enchantress only has the following Argothian_Enchantress.txt file:
- Code: Select all
name=Argothian Enchantress
url=http://magiccards.info/us/en/234.html
image=http://magiccards.info/scans/en/us/234.jpg
value=4.617
rarity=R
type=Creature
subtype=Human,Druid
cost={1}{G}
pt=0/1
ability=shroud
timing=main
requires_groovy_code=Enchantress's Presence
-
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 Aswan jaguar » 28 Jul 2013, 05:13
You may want to add Verduran Enchantress that has a similar (may) ability,too.
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8129
- Joined: 13 May 2010, 12:17
- Has thanked: 748 times
- Been thanked: 477 times
Re: Adding new cards with Groovy
by melvin » 28 Jul 2013, 06:25
Available since 1.34Aswan jaguar wrote:You may want to add Verduran Enchantress that has a similar (may) ability,too.

-
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 » 30 Jul 2013, 14:08

Magarena/scripts/Ethereal_Armor.txt
- Code: Select all
name=Ethereal Armor
url=http://magiccards.info/rtr/en/9.html
image=http://magiccards.info/scans/en/rtr/9.jpg
value=3.189
rarity=C
type=Enchantment
subtype=Aura
cost={W}
timing=aura
given_ability=first strike
enchant=pump,pos creature
requires_groovy_code
- Code: Select all
[
new MagicStatic(MagicLayer.ModPT) {
@Override
public void modPowerToughness(final MagicPermanent source, final MagicPermanent permanent, final MagicPowerToughness pt) {
final int amt = source.getController().getNrOfPermanents(MagicType.Enchantment)
pt.add(amt, amt);
}
@Override
public boolean accept(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
return MagicStatic.acceptLinked(game, source, target);
}
}
]
-
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 » 31 Jul 2013, 02:26
"ethereal armor"
this is just as deadly as "ancestral mask", did u make this for the enchantress deck?
this is just as deadly as "ancestral mask", did u make this for the enchantress deck?

-
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 » 31 Jul 2013, 02:44
Yes, in a way. Ethereal Armor has been near the top of my list of card to work on (based on popularity in top 8 decks biased toward recent ones) for some time. Seeing your Enchantment based deck made me work on it first.
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Who is online
Users browsing this forum: No registered users and 16 guests