It is currently 06 Jul 2025, 17:18
   
Text Size

Adding new cards with Groovy

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

Re: Adding new cards with Groovy

Postby ember hauler » 18 Aug 2013, 18:05

melvin wrote:
ember hauler wrote:I made a Rusted Slasher card, but it has a strange behaviour.
Thanks! Card looks good, do submit on http://www.firemind.ch/card_script_submissions/new.
Done.
ember hauler
 
Posts: 79
Joined: 14 Aug 2013, 08:13
Has thanked: 27 times
Been thanked: 14 times

Re: Adding new cards with Groovy

Postby melvin » 21 Aug 2013, 13:03

Image

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
Magarena/scripts/Master_Transmuter.groovy
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()));
                }
            });
        }
    }
]
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 » 21 Aug 2013, 16:02

Image
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
Primordial_Sage.groovy
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()));
            }
        }
    }
]
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 Aug 2013, 15:06

Already posted on firemind.ch :)

Image
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
Regal_Force.groovy
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));
        }
    }
]
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 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
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) {
//            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.
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 » 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)
];
write
Code: Select all
return [
    new MagicPayManaCostTapEvent(source,"{R}"),
    new MagicSacrificePermanentEvent(source,MagicTargetChoice.SACRIFICE_CREATURE)
];
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 » 23 Aug 2013, 04:42

Updated
Image
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));
                    }
                });
            }
        }
    ]
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 » 23 Aug 2013, 06:53

Thanks for the script :D 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.
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 melvin » 24 Aug 2013, 15:04

Library search!

Image

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
Magarena/scripts/Rampant_Growth.groovy
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\$."
            ));
        }
    }
]
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 melvin » 25 Aug 2013, 05:28

Image

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
Magarena/scripts/Farseek.groovy
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\$."
            ));
        }
    }
]
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 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. :lol: But I still like it.
User avatar
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

Postby hong yie » 25 Aug 2013, 06:22

BETA test required
Image
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
Farhaven_Elf.groovy
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\$."
            ));
        }
    }
]
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 » 25 Aug 2013, 06:44

Image
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
Ondu_giant.groovy
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\$."
            ));
        }
    }
]
these codes require Magarena version... ??
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 » 25 Aug 2013, 08:17

hong yie wrote:these codes require Magarena version... ??
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/
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 melvin » 25 Aug 2013, 09:33

@hong yie: Thanks for the two cards, that's fast work :D 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
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

PreviousNext

Return to Magarena

Who is online

Users browsing this forum: No registered users and 7 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 10 minutes)
Most users ever online was 5050 on 26 Jun 2025, 06:02

Users browsing this forum: No registered users and 7 guests

Login Form