It is currently 06 Sep 2025, 21:21
   
Text Size

Adding new cards with Groovy

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

Re: Adding new cards with Groovy

Postby hong yie » 24 Apr 2014, 00:58

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 dies, shuffle it into its owner's library.
timing=main
Updated ability trigger
i hope this script do the trick. :)
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 » 24 Apr 2014, 13:45

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 dies, shuffle it into its owner's library.
timing=main
Updated ability trigger
i hope this script do the trick. :)
Ok, I get the hint - I've enabled shuffling permanents into the library via 'shuffle SN into its owner's library' with scripts. May take a little longer to push as I'm also looking at letting cards know where they are :)
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 » 02 May 2014, 05:35

correction on Reveillark txt code.

Reveillark.txt
Code: Select all
name=Reveillark
url=http://magiccards.info/mma/en/26.html
image=http://magiccards.info/scans/en/mma/26.jpg
value=4.241
rarity=R
type=Creature
subtype=Elemental
cost={4}{W}
pt=4/3
ability=flying;evoke {5}{W}
timing=main
requires_groovy_code
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 » 02 May 2014, 08:31

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 » 03 May 2014, 16:17

melvin wrote:Thanks for the fix, applied in https://code.google.com/p/magarena/sour ... f674209974
i checked the fix, the evoke cost still not corrected. :)
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 » 03 May 2014, 20:54

I've submitted the 'fix' for Reveillark but it's still going to be in the incomplete folder as it involves multiple targets (and an 'up to' target as well) and there's currently no function for the AI to perform that, as the options are 0, 1 or 2 as well as the main 'may' choice.

I'd like the incomplete folder to be more than just a 'dumping-ground', I do like the reference of a '(nearly) OK Corral' - thanks Frank ;) Seeing what other people have been trying/working on/need help with can allow a more collaborative feel, than single people working on individual cards.

As always, getting one card to work will usually open the gates for a few more ;)

https://code.google.com/p/magarena/sour ... incomplete

Some may be more stubborn than others but these cards can always return to the herd :)
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 » 05 May 2014, 22:06

i tried this code, but the X damage is not dealt.
i wonder which part is wrong here?

Nin__the_Pain_Artist.groovy
Code: Select all
[
    new MagicPermanentActivation(
        new MagicActivationHints(MagicTiming.Removal),
        "Damage"
    ) {

        @Override
        public Iterable getCostEvent(final MagicPermanent source) {
            return [
            new MagicPayManaCostEvent(source,"{X}{U}{R}"),
            new MagicTapEvent(source)
         ];
        }

        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
         final int amount=payedCost.getX();
            return new MagicEvent(
                source,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                new MagicDamageTargetPicker(1),
                this,
                "SN deals X damage to target creature. That creature's controller draws X cards."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTarget(game,new MagicTargetAction() {
                public void doAction(final MagicTarget target) {
               final int amount = event.getRefInt();
                    final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
                    game.doAction(new MagicDealDamageAction(damage));
               game.doAction(new MagicDrawAction(target.getController(),amount));
                }
            });
        }
    }
]
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 » 06 May 2014, 00:11

hong yie wrote:i tried this code, but the X damage is not dealt.
i wonder which part is wrong here?

Nin__the_Pain_Artist.groovy
Code: Select all
[
    new MagicPermanentActivation(
        new MagicActivationHints(MagicTiming.Removal),
        "Damage"
    ) {

        @Override
        public Iterable getCostEvent(final MagicPermanent source) {
            return [
            new MagicPayManaCostEvent(source,"{X}{U}{R}"),
            new MagicTapEvent(source)
         ];
        }

        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
         final int amount=payedCost.getX();
            return new MagicEvent(
                source,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                new MagicDamageTargetPicker(1),
                this,
                "SN deals X damage to target creature. That creature's controller draws X cards."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTarget(game,new MagicTargetAction() {
                public void doAction(final MagicTarget target) {
               final int amount = event.getRefInt();
                    final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
                    game.doAction(new MagicDealDamageAction(damage));
               game.doAction(new MagicDrawAction(target.getController(),amount));
                }
            });
        }
    }
]
The event.getRefInt() hasn't been defined in the event.
Code: Select all
            return new MagicEvent(
                source,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                new MagicDamageTargetPicker(amount),
                amount,
                this,
                "SN deals X damage to target creature. That creature's controller draws X cards."
            );
Or you can getX later on:
Code: Select all
           final int amount = event.getCardOnStack().getX();
           final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
           game.doAction(new MagicDealDamageAction(damage));
           game.doAction(new MagicDrawAction(target.getController(),amount));
This should work:
Code: Select all
[
    new MagicPermanentActivation(
        new MagicActivationHints(MagicTiming.Removal),
        "Damage"
    ) {

        @Override
        public Iterable getCostEvent(final MagicPermanent source) {
            return [
            new MagicPayManaCostEvent(source,"{X}{U}{R}"),
            new MagicTapEvent(source)
         ];
        }

        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
         final int amount=payedCost.getX();
            return new MagicEvent(
                source,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                new MagicDamageTargetPicker(amount),
                this,
                "SN deals X damage to target creature. That creature's controller draws X cards."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTarget(game,new MagicTargetAction() {
                final MagicPermanent creature ->
                final int amount = event.getCardOnStack().getX();
                final MagicDamage damage=new MagicDamage(event.getSource(),creature,amount);
                game.doAction(new MagicDealDamageAction(damage));
                game.doAction(new MagicDrawAction(creature.getController(),amount));
            });
        }
    }
]
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 » 06 May 2014, 00:39

thanx, for the fix, shawnie
putting it to test... :)
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 » 09 May 2014, 22:29

i tried the script from shawnie.
i got crash when starting the game.

Code: Select all
1 error

   at java.util.concurrent.FutureTask.report(Unknown Source)
   at java.util.concurrent.FutureTask.get(Unknown Source)
   at javax.swing.SwingWorker.get(Unknown Source)
   at magic.ui.screen.DuelGameScreen$1.done(DuelGameScreen.java:44)
   ... 20 more
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\Games\Magarena-1.35\Magarena\scripts\Nin__the_Pain_Artist.groovy: 30: unexpected token: creature @ line 30, column 26.
this part maybe the cause
Code: Select all
      @Override
      public void executeEvent(final MagicGame game, final MagicEvent event) {
         event.processTarget(game,new MagicTargetAction() {
            final MagicPermanent creature -> final int amount = event.getCardOnStack().getX();
            final MagicDamage damage=new MagicDamage(event.getSource(),creature,amount);
            game.doAction(new MagicDealDamageAction(damage));
            game.doAction(new MagicDrawAction(creature.getController(),amount));
         });
      }
   }
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 » 09 May 2014, 23:08

Whoops, yes, made a bit of a mess on that one. This -really- should work:
Code: Select all
[
    new MagicPermanentActivation(
        new MagicActivationHints(MagicTiming.Removal),
        "Damage"
    ) {

        @Override
        public Iterable getCostEvent(final MagicPermanent source) {
            return [
            new MagicPayManaCostEvent(source,"{X}{U}{R}"),
            new MagicTapEvent(source)
         ];
        }

        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
         final int amount=payedCost.getX();
            return new MagicEvent(
                source,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                new MagicDamageTargetPicker(amount),
                amount,
                this,
                "SN deals "+amount+" damage to target creature. That creature's controller draws "+amount+" cards."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTargetPermanent(game, {
                final MagicPermanent creature ->
                final int amount = event.getRefInt();
                final MagicDamage damage=new MagicDamage(event.getSource(),creature,amount);
                game.doAction(new MagicDealDamageAction(damage));
                game.doAction(new MagicDrawAction(creature.getController(),amount));
            });
        }
    }
]
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 » 10 May 2014, 15:08

the script seemed to work,
i know it work when i try it on lethal damage. but i can't see the damage sign dealt by "nin" when the target survive, not because prevented, just not enough damage.
every damage dealt will leave red mark right ? this kinda confusing when the damage is not lethal, need to know amount of damage to finish the creature.
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 » 10 May 2014, 15:15

I'm having no issue with that - do you have a card you can cast in hand or activate on the battlefield as the damage will wear off when the turn automatically skips to the end of turn.
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 » 11 May 2014, 05:53

ShawnieBoy wrote:I'm having no issue with that - do you have a card you can cast in hand or activate on the battlefield as the damage will wear off when the turn automatically skips to the end of turn.
will test it some more.
it could be skipped as you said.
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 » 11 May 2014, 16:56

i try to script "Abyssal Persecutor" from "Platinum Angel"
just added a "!" after if. i'm putting it to test, just wonder will this work?

Code: Select all
[
    new MagicIfPlayerWouldLoseTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicLoseGameAction loseAct) {
            if !(permanent.isController(loseAct.getPlayer())) {
                loseAct.setPlayer(MagicPlayer.NONE);
            }
            return MagicEvent.NONE;
        }
    }
]
User avatar
hong yie
Programmer
 
Posts: 216
Joined: 10 Mar 2013, 06:44
Location: Jakarta
Has thanked: 75 times
Been thanked: 9 times

PreviousNext

Return to Magarena

Who is online

Users browsing this forum: No registered users and 15 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 15 users online :: 0 registered, 0 hidden and 15 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 15 guests

Login Form