It is currently 08 Sep 2025, 05:33
   
Text Size

Adding new cards with Groovy

Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins

Re: Adding new cards with Groovy

Postby frank » 11 Apr 2014, 14:31

It does make sense. Thank you
frank
 
Posts: 46
Joined: 24 Mar 2014, 00:59
Has thanked: 8 times
Been thanked: 2 times

Re: Adding new cards with Groovy

Postby frank » 11 Apr 2014, 17:58

Image 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?
frank
 
Posts: 46
Joined: 24 Mar 2014, 00:59
Has thanked: 8 times
Been thanked: 2 times

Re: Adding new cards with Groovy

Postby ShawnieBoy » 11 Apr 2014, 18:52

frank wrote:Image 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?
Yep, needs to be put on the stack, then when it resolves you look and choose.
User avatar
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

Postby hong yie » 18 Apr 2014, 08:33

Image

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
Damia__Sage_of_Stone.groovy
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));
        }
    }
]
i 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:

We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
User avatar
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

Postby hong yie » 18 Apr 2014, 08:49

Image

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
Wight_of_Precinct_Six.groovy
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);
        }
    }
]
User avatar
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

Postby 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.

hong yie wrote:Image

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
Damia__Sage_of_Stone.groovy
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));
        }
    }
]
i 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:

We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
frank
 
Posts: 46
Joined: 24 Mar 2014, 00:59
Has thanked: 8 times
Been thanked: 2 times

Re: Adding new cards with Groovy

Postby melvin » 18 Apr 2014, 11:47

hong yie wrote:i just need a reference to script "skip your draw phase" to complete this card.
That is not implementable at the moment.

Don't forget to submit on firemind.ch. Thanks!
User avatar
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

Postby 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.
User avatar
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

Postby ShawnieBoy » 18 Apr 2014, 21:56

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.
Unfortunately, as yet, no.

A track for the life gained and lost per player would be useful for some cards.
User avatar
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

Postby hong yie » 20 Apr 2014, 06:10

Image

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
Nighthowler.groovy
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);
        }
    }
]
the firemind.ch seem doesn't work. so i submit it here.
User avatar
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

Postby 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
tried submitting through firemind.ch, failed...
User avatar
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

Postby 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.
User avatar
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

Postby ShawnieBoy » 22 Apr 2014, 13:40

hong yie wrote: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
tried submitting through firemind.ch, failed...
This isn't quite right - Alabaster Dragon shouldn't get shuffled in if you discard it.
User avatar
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

Postby hong yie » 23 Apr 2014, 02:12

ShawnieBoy wrote:This isn't quite right - Alabaster Dragon shouldn't get shuffled in if you discard it.
need specific ability that only trigger when the dragon dies?
User avatar
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

Postby jerichopumpkin » 23 Apr 2014, 12:01

hong yie wrote:
ShawnieBoy wrote:This isn't quite right - Alabaster Dragon shouldn't get shuffled in if you discard it.
need specific ability that only trigger when the dragon dies?
try looking into Solemn Simulacrum or Viridian Emissary, they both have a "when dies" trigger. Worldspine Wurm also
jerichopumpkin
 
Posts: 212
Joined: 12 Sep 2013, 11:21
Has thanked: 19 times
Been thanked: 13 times

PreviousNext

Return to Magarena

Who is online

Users browsing this forum: No registered users and 16 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 16 users online :: 0 registered, 0 hidden and 16 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 16 guests

Login Form