Adding new cards with Groovy
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Adding new cards with Groovy
by frank » 11 Apr 2014, 17:58
The way I implemented it:
The Oni damages a player in combat, the triggered ability is put on stack and as soon its there, you get to see opponents hand and get to choose the card ( or decide not to, working on that).
But that's wrong isn't it? It needs to be put on stack to be there to be countered, and as it resolves you get to see the hand and choose, right?
Re: Adding new cards with Groovy
by ShawnieBoy » 11 Apr 2014, 18:52
Yep, needs to be put on the stack, then when it resolves you look and choose.frank wrote:I got a timing Question about cards like Silent-Blade Oni .
The way I implemented it:
The Oni damages a player in combat, the triggered ability is put on stack and as soon its there, you get to see opponents hand and get to choose the card ( or decide not to, working on that).
But that's wrong isn't it? It needs to be put on stack to be there to be countered, and as it resolves you get to see the hand and choose, right?
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 18 Apr 2014, 08:33

Damia__Sage_of_Stone.txt
- Code: Select all
name=Damia, Sage of Stone
url=http://magiccards.info/cmd/en/191.html
image=http://magiccards.info/scans/en/cmd/191.jpg
value=4.021
rarity=M
type=Legendary,Creature
subtype=Gorgon,Wizard
cost={4}{G}{U}{B}
pt=4/4
ability=deadtouch
timing=main
requires_groovy_code
- Code: Select all
[
new MagicAtUpkeepTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer upkeepPlayer) {
return (permanent.getController() == upkeepPlayer && permanent.getController().getHandSize()<7) ? new MagicEvent(
permanent,
permanent.getController(),
this,
"if PN have fewer than seven cards in hand, draw cards equal to the difference."
):
MagicEvent.NONE
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
final MagicPlayer player = event.getPlayer();
final int amount = 7 - player.getHandSize() ;
game.doAction(new MagicDrawAction(event.getPlayer(),amount));
}
}
]
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
-
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 » 18 Apr 2014, 08:49

Wight_of_Precinct_Six.txt
- Code: Select all
name=Wight of Precinct Six
url=http://magiccards.info/ddm/en/46.html
image=http://magiccards.info/scans/en/ddm/46.jpg
value=3.778
rarity=U
type=Creature
subtype=Zombie
cost={1}{B}
pt=1/1
timing=fmain
requires_groovy_code
- Code: Select all
[
new MagicStatic(MagicLayer.ModPT) {
@Override
public void modPowerToughness(final MagicPermanent source,final MagicPermanent permanent,final MagicPowerToughness pt) {
final MagicGame game = source.getGame();
final int size =
game.filterCards(player,MagicTargetFilterFactory.CREATURE_CARD_FROM_OPPONENT_GRAVEYARDS).size();
pt.add(size,size);
}
}
]
-
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 frank » 18 Apr 2014, 11:46
Adding and skipping phases has yet to be implemented, as far as I can see.
MagicGame does have some methods like changePhase or nextPhase though, maybe you could find a workaround.
MagicGame does have some methods like changePhase or nextPhase though, maybe you could find a workaround.
hong yie wrote:
Damia__Sage_of_Stone.txtDamia__Sage_of_Stone.groovy
- Code: Select all
name=Damia, Sage of Stone
url=http://magiccards.info/cmd/en/191.html
image=http://magiccards.info/scans/en/cmd/191.jpg
value=4.021
rarity=M
type=Legendary,Creature
subtype=Gorgon,Wizard
cost={4}{G}{U}{B}
pt=4/4
ability=deadtouch
timing=main
requires_groovy_codei just need a reference to script "skip your draw phase" to complete this card. i tried to search in firemind.ch but the page shows this message:
- Code: Select all
[
new MagicAtUpkeepTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer upkeepPlayer) {
return (permanent.getController() == upkeepPlayer && permanent.getController().getHandSize()<7) ? new MagicEvent(
permanent,
permanent.getController(),
this,
"if PN have fewer than seven cards in hand, draw cards equal to the difference."
):
MagicEvent.NONE
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
final MagicPlayer player = event.getPlayer();
final int amount = 7 - player.getHandSize() ;
game.doAction(new MagicDrawAction(event.getPlayer(),amount));
}
}
]We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
Re: Adding new cards with Groovy
by melvin » 18 Apr 2014, 11:47
That is not implementable at the moment.hong yie wrote:i just need a reference to script "skip your draw phase" to complete this card.
Don't forget to submit on firemind.ch. Thanks!
-
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 » 18 Apr 2014, 14:40
does magarena have a public variable that keeps amount of life gained in a turn, then reset at the end phase? needed for some cards.
-
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 ShawnieBoy » 18 Apr 2014, 21:56
Unfortunately, as yet, no.hong yie wrote:does magarena have a public variable that keeps amount of life gained in a turn, then reset at the end phase? needed for some cards.
A track for the life gained and lost per player would be useful for some cards.
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 20 Apr 2014, 06:10

Nighthowler.txt
- Code: Select all
name=Nighthowler
url=http://magiccards.info/ths/en/98.html
image=http://magiccards.info/scans/en/ths/98.jpg
value=3.603
rarity=R
type=Enchantment,Creature
subtype=Horror
cost={1}{B}{B}
pt=0/0
ability=bestow {2}{B}{B}
timing=main
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 size =
game.filterCards(player,MagicTargetFilterFactory.CREATURE_CARD_FROM_ALL_GRAVEYARDS).size();
pt.add(size,size);
}
@Override
public boolean accept(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
return source == target || MagicStatic.acceptLinked(game, source, target);
}
}
]
-
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 Apr 2014, 06:03
Alabaster_Dragon.txt
- Code: Select all
name=Alabaster Dragon
url=http://magiccards.info/wl/en/.html
image=http://magiccards.info/scans/en/wl/.jpg
value=3.269
rarity=R
type=Creature
subtype=Dragon
cost={4}{W}{W}
pt=4/4
ability=flying;\
When SN is put into a graveyard from anywhere, shuffle it into its owner's library.
timing=main
-
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 Apr 2014, 07:36
Thanks, added in https://code.google.com/p/magarena/sour ... 13ea114061
All the previously submitted cards have also been merged.
All the previously submitted cards have also been merged.
-
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 ShawnieBoy » 22 Apr 2014, 13:40
This isn't quite right - Alabaster Dragon shouldn't get shuffled in if you discard it.hong yie wrote:Alabaster_Dragon.txttried submitting through firemind.ch, failed...
- Code: Select all
name=Alabaster Dragon
url=http://magiccards.info/wl/en/.html
image=http://magiccards.info/scans/en/wl/.jpg
value=3.269
rarity=R
type=Creature
subtype=Dragon
cost={4}{W}{W}
pt=4/4
ability=flying;\
When SN is put into a graveyard from anywhere, shuffle it into its owner's library.
timing=main
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 23 Apr 2014, 02:12
need specific ability that only trigger when the dragon dies?ShawnieBoy wrote:This isn't quite right - Alabaster Dragon shouldn't get shuffled in if you discard it.
-
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 jerichopumpkin » 23 Apr 2014, 12:01
try looking into Solemn Simulacrum or Viridian Emissary, they both have a "when dies" trigger. Worldspine Wurm alsohong yie wrote:need specific ability that only trigger when the dragon dies?ShawnieBoy wrote:This isn't quite right - Alabaster Dragon shouldn't get shuffled in if you discard it.
- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Who is online
Users browsing this forum: No registered users and 16 guests