Adding new cards with Groovy
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Adding new cards with Groovy
by ember hauler » 18 Aug 2013, 18:05
Done.melvin wrote:Thanks! Card looks good, do submit on http://www.firemind.ch/card_script_submissions/new.ember hauler wrote:I made a Rusted Slasher card, but it has a strange behaviour.
- 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 » 21 Aug 2013, 13:03

Magarena/scripts/Master_Transmuter.txt
- Code: Select all
name=Master Transmuter
url=http://magiccards.info/arc/en/7.html
image=http://magiccards.info/scans/en/arc/7.jpg
value=3.717
rarity=R
type=Artifact,Creature
subtype=Human,Artificer
cost={3}{U}
pt=1/2
timing=main
requires_groovy_code
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Token),
"Put"
) {
@Override
public MagicEvent[] getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostTapEvent(source, "{U}"),
new MagicBounceChosenPermanentEvent(source, MagicTargetChoice.ARTIFACT_YOU_CONTROL)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
MagicTargetChoice.ARTIFACT_CARD_FROM_HAND,
new MagicGraveyardTargetPicker(true),
this,
"PN puts an artifact card\$ from his or her hand onto the battlefield."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetCard(game,new MagicCardAction() {
public void doAction(final MagicCard card) {
game.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersHand));
game.doAction(new MagicPlayCardAction(card,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 hong yie » 21 Aug 2013, 16:02

Primordial_Sage.txt
- Code: Select all
name=Primordial Sage
url=http://magiccards.info/rav/en/177.html
image=http://magiccards.info/scans/en/rav/177.jpg
value=4.043
rarity=R
type=Creature
subtype=Spirit
cost={4}{G}{G}
pt=4/5
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().isCreature()) ?
new MagicEvent(
permanent,
new MagicSimpleMayChoice(
MagicSimpleMayChoice.DRAW_CARDS,
1,
MagicSimpleMayChoice.DEFAULT_NONE
),
this,
"PN may\$ draw a card."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()) {
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 » 22 Aug 2013, 15:06
Already posted on firemind.ch 

Regal_Force.txt


Regal_Force.txt
- Code: Select all
name=Regal Force
url=http://magiccards.info/eve/en/74.html
image=http://magiccards.info/scans/en/eve/74.jpg
value=4.241
rarity=R
type=Creature
subtype=Elemental
cost={4}{G}{G}{G}
pt=5/5
timing=main
requires_groovy_code
- Code: Select all
[
new MagicWhenComesIntoPlayTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPayedCost payedCost) {
return new MagicEvent(
permanent,
this,
"PN draws a cards for each green creature PN controls."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
final MagicPlayer player=event.getPlayer();
final int amount = player.getNrOfPermanents(MagicTargetFilter.TARGET_GREEN_CREATURE_YOU_CONTROL);
game.doAction(new MagicDrawAction(player,amount));
}
}
]
-
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 Aug 2013, 16:20
this one is almost complete,
the script is similar to brion, the difference is this one can pick any creature including itself. help needed pls.
Bloodshot_Cyclops.txt
the script is similar to brion, the difference is this one can pick any creature including itself. help needed pls.

Bloodshot_Cyclops.txt
- Code: Select all
name=Bloodshot Cyclops
url=http://magiccards.info/8e/en/179.html
image=http://magiccards.info/scans/en/8e/179.jpg
value=3.851
rarity=R
type=Creature
subtype=Giant
cost={5}{R}
pt=4/4
timing=smain
requires_groovy_code
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public MagicEvent[] getCostEvent(final MagicPermanent source) {
// final MagicTargetFilter<MagicPermanent> targetFilter=new MagicOtherPermanentTargetFilter(
// MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL,source);
// final MagicTargetChoice targetChoice=new MagicTargetChoice(
// targetFilter,false,MagicTargetHint.None,"a creature other than " + source + " to sacrifice");
return [
new MagicPayManaCostTapEvent(source,"{R}"),
new MagicSacrificePermanentEvent(source,targetChoice)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_PLAYER,
payedCost.getTarget(),
this,
"SN deals damage equal to the power of RN to target player\$."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPlayer(game,new MagicPlayerAction() {
public void doAction(final MagicPlayer player) {
final MagicPermanent sacrificed=event.getRefPermanent();
final MagicDamage damage=new MagicDamage(event.getSource(),player,sacrificed.getPower());
game.doAction(new MagicDealDamageAction(damage));
}
});
}
}
]
Last edited by hong yie on 23 Aug 2013, 04:40, 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 melvin » 23 Aug 2013, 02:58
This is actually easier as "sacrifice a creature" is built in, so instead of
- Code: Select all
return [
new MagicPayManaCostTapEvent(source,"{R}"),
new MagicSacrificePermanentEvent(source,targetChoice)
];
- Code: Select all
return [
new MagicPayManaCostTapEvent(source,"{R}"),
new MagicSacrificePermanentEvent(source,MagicTargetChoice.SACRIFICE_CREATURE)
];
-
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 » 23 Aug 2013, 04:42
Updated

Bloodshot_Cyclops.groovy

- Code: Select all
name=Bloodshot Cyclops
url=http://magiccards.info/8e/en/179.html
image=http://magiccards.info/scans/en/8e/179.jpg
value=3.851
rarity=R
type=Creature
subtype=Giant
cost={5}{R}
pt=4/4
timing=smain
requires_groovy_code
Bloodshot_Cyclops.groovy
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public MagicEvent[] getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostTapEvent(source,"{R}"),
new MagicSacrificePermanentEvent(source,MagicTargetChoice.SACRIFICE_CREATURE)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_PLAYER,
payedCost.getTarget(),
this,
"SN deals damage equal to the power of RN to target player\$."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPlayer(game,new MagicPlayerAction() {
public void doAction(final MagicPlayer player) {
final MagicPermanent sacrificed=event.getRefPermanent();
final MagicDamage damage=new MagicDamage(event.getSource(),player,sacrificed.getPower());
game.doAction(new MagicDealDamageAction(damage));
}
});
}
}
]
-
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 » 23 Aug 2013, 06:53
Thanks for the script
there are a couple of minor fixes:
new MagicPayManaCostTapEvent(source,"{R}") should be new MagicTapEvent(source) (the cost of the ability does not require mana)
The script is for "target player" but it should be "target creature or player"
Do submit on http://www.firemind.ch/card_script_submissions/new when it is ready.

new MagicPayManaCostTapEvent(source,"{R}") should be new MagicTapEvent(source) (the cost of the ability does not require mana)
The script is for "target player" but it should be "target creature or player"
Do submit on http://www.firemind.ch/card_script_submissions/new when it is ready.
-
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 » 24 Aug 2013, 15:04
Library search!

Magarena/scripts/Rampant_Growth.txt

Magarena/scripts/Rampant_Growth.txt
- Code: Select all
name=Rampant Growth
url=http://magiccards.info/m12/en/190.html
image=http://magiccards.info/scans/en/m12/190.jpg
value=4.638
rarity=C
type=Sorcery
cost={1}{G}
timing=main
requires_groovy_code
- Code: Select all
[
new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
this,
"PN searches his or her library for a basic land card and put that card onto the battlefield tapped. Then shuffle PN's library."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.addEvent(new MagicEvent(
event.getSource(),
MagicTargetChoice.BASIC_LAND_CARD_FROM_LIBRARY,
{
final MagicGame G, final MagicEvent E ->
E.processTargetCard(G, {
final MagicCard card ->
G.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersLibrary));
G.doAction(new MagicPlayCardAction(card,event.getPlayer(),MagicPlayMod.TAPPED));
G.doAction(new MagicShuffleLibraryAction(event.getPlayer()));
} as MagicCardAction);
} as MagicEventAction,
"Selected basic land 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 melvin » 25 Aug 2013, 05:28

Magarena/scripts/Farseek.txt
- Code: Select all
name=Farseek
url=http://magiccards.info/m13/en/170.html
image=http://magiccards.info/scans/en/m13/170.jpg
value=4.638
rarity=C
type=Sorcery
cost={1}{G}
timing=main
requires_groovy_code
- Code: Select all
[
new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
this,
"PN searches his or her library for a Plains, Island, Swamp, or Mountain card and put that card onto the battlefield tapped. Then shuffle PN's library."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.addEvent(new MagicEvent(
event.getSource(),
MagicTargetChoice.PLAINS_ISLAND_SWAMP_OR_MOUNTAIN_CARD_FROM_LIBRARY,
{
final MagicGame G, final MagicEvent E ->
E.processTargetCard(G, {
final MagicCard card ->
G.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersLibrary));
G.doAction(new MagicPlayCardAction(card,E.getPlayer(),MagicPlayMod.TAPPED));
G.doAction(new MagicShuffleLibraryAction(E.getPlayer()));
} as MagicCardAction);
} as MagicEventAction,
"Selected 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 Huggybaby » 25 Aug 2013, 05:35
Rampant Growth is one of my favorite cards. Maybe it's old and not popular any more...like me.
But I still like it.

-
Huggybaby - Administrator
- Posts: 3226
- Joined: 15 Jan 2006, 19:44
- Location: Finally out of Atlanta
- Has thanked: 741 times
- Been thanked: 601 times
Re: Adding new cards with Groovy
by hong yie » 25 Aug 2013, 06:22
BETA test required

Farhaven_Elf.txt

Farhaven_Elf.txt
- Code: Select all
name=Farhaven Elf
url=http://magiccards.info/shm/en/113.html
image=http://magiccards.info/scans/en/shm/113.jpg
value=3.618
rarity=C
type=Creature
subtype=Elf,Druid
cost={2}{G}
pt=1/1
timing=main
requires_groovy_code
- Code: Select all
[
new MagicWhenComesIntoPlayTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
return new MagicEvent(
permanent,
this,
"PN searches his or her library for a basic land card and put that card onto the battlefield tapped. Then shuffle PN's library."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.addEvent(new MagicEvent(
event.getSource(),
MagicTargetChoice.BASIC_LAND_CARD_FROM_LIBRARY,
{
final MagicGame G, final MagicEvent E ->
E.processTargetCard(G, {
final MagicCard card ->
G.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersLibrary));
G.doAction(new MagicPlayCardAction(card,event.getPlayer(),MagicPlayMod.TAPPED));
G.doAction(new MagicShuffleLibraryAction(event.getPlayer()));
} as MagicCardAction);
} as MagicEventAction,
"Selected basic land card\$."
));
}
}
]
-
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 » 25 Aug 2013, 06:44

Ondu_giant.txt
- Code: Select all
name=Ondu Giant
url=http://magiccards.info/pc2/en/71.html
image=http://magiccards.info/scans/en/pc2/71.jpg
value=3.033
rarity=C
type=Creature
subtype=Giant,Druid
cost={3}{G}
pt=2/4
timing=main
requires_groovy_code
- Code: Select all
[
new MagicWhenComesIntoPlayTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
return new MagicEvent(
permanent,
this,
"PN searches his or her library for a basic land card and put that card onto the battlefield tapped. Then shuffle PN's library."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.addEvent(new MagicEvent(
event.getSource(),
MagicTargetChoice.BASIC_LAND_CARD_FROM_LIBRARY,
{
final MagicGame G, final MagicEvent E ->
E.processTargetCard(G, {
final MagicCard card ->
G.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersLibrary));
G.doAction(new MagicPlayCardAction(card,event.getPlayer(),MagicPlayMod.TAPPED));
G.doAction(new MagicShuffleLibraryAction(event.getPlayer()));
} as MagicCardAction);
} as MagicEventAction,
"Selected basic land card\$."
));
}
}
]
-
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 » 25 Aug 2013, 08:17
1.41, the August release which should be out next week. You can preview the upcoming version from https://buildhive.cloudbees.com/job/mel ... sfulBuild/hong yie wrote:these codes require Magarena version... ??
-
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 » 25 Aug 2013, 09:33
@hong yie: Thanks for the two cards, that's fast work
I've added them in as
https://code.google.com/p/magarena/sour ... en_Elf.txt
https://code.google.com/p/magarena/sour ... Elf.groovy
and
https://code.google.com/p/magarena/sour ... _Giant.txt
Ondu Giant doesn't need a Groovy script as it can use reuse Farhaven Elf's script with requires_groovy_code=Farhaven Elf

https://code.google.com/p/magarena/sour ... en_Elf.txt
https://code.google.com/p/magarena/sour ... Elf.groovy
and
https://code.google.com/p/magarena/sour ... _Giant.txt
Ondu Giant doesn't need a Groovy script as it can use reuse Farhaven Elf's script with requires_groovy_code=Farhaven Elf
-
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 5 guests