Page 6 of 28

Re: Adding new cards with Groovy

PostPosted: 18 Aug 2013, 18:05
by ember hauler
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.

Re: Adding new cards with Groovy

PostPosted: 21 Aug 2013, 13:03
by melvin
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()));
                }
            });
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 21 Aug 2013, 16:02
by hong yie
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()));
            }
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 22 Aug 2013, 15:06
by hong yie
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));
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 22 Aug 2013, 16:20
by hong yie
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));
                }
            });
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 23 Aug 2013, 02:58
by melvin
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)
];

Re: Adding new cards with Groovy

PostPosted: 23 Aug 2013, 04:42
by hong yie
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));
                    }
                });
            }
        }
    ]

Re: Adding new cards with Groovy

PostPosted: 23 Aug 2013, 06:53
by melvin
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.

Re: Adding new cards with Groovy

PostPosted: 24 Aug 2013, 15:04
by melvin
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\$."
            ));
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 25 Aug 2013, 05:28
by melvin
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\$."
            ));
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 25 Aug 2013, 05:35
by Huggybaby
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.

Re: Adding new cards with Groovy

PostPosted: 25 Aug 2013, 06:22
by hong yie
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\$."
            ));
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 25 Aug 2013, 06:44
by hong yie
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... ??

Re: Adding new cards with Groovy

PostPosted: 25 Aug 2013, 08:17
by melvin
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/

Re: Adding new cards with Groovy

PostPosted: 25 Aug 2013, 09:33
by melvin
@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