It is currently 13 May 2025, 08:36
   
Text Size

Adding new cards with Groovy

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

Re: Adding new cards with Groovy

Postby melvin » 15 Aug 2013, 02:51

We represent them as two separate static ability as they apply in different layers. The +0/+1 should be as follows, note the layer is ModPT instead of Ability.

Code: Select all
    new MagicStatic(
        MagicLayer.ModPT,
        MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL) {
        @Override
        public void modPowerToughness(final MagicPermanent source,final MagicPermanent permanent,final MagicPowerToughness pt) {
            pt.add(0,1);
        }
    }
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 drooone » 15 Aug 2013, 15:04

Does Magarena support the "Convoke" ability?
drooone
 
Posts: 2
Joined: 15 Aug 2013, 15:00
Has thanked: 0 time
Been thanked: 0 time

Re: Adding new cards with Groovy

Postby hong yie » 15 Aug 2013, 21:32

Spidersilk code updated

Image
Spidersilk_Armor.txt
Code: Select all
name=Spidersilk Armor
url=http://magiccards.info/ddg/en/32.html
image=http://magiccards.info/scans/en/ddg/32.jpg
value=4.262
rarity=C
type=Enchantment
cost={2}{G}
static=player
timing=enchantment
requires_groovy_code
Spidersilk_Armor.groovy
Code: Select all
[
    new MagicStatic(
        MagicLayer.Ability,
        MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL) {
        @Override
        public void modAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final Set<MagicAbility> flags) {
            flags.add(MagicAbility.Reach);
        }
   },
    new MagicStatic(
        MagicLayer.ModPT,
        MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL) {
        @Override
        public void modPowerToughness(final MagicPermanent source,final MagicPermanent permanent,final MagicPowerToughness pt) {
            pt.add(0,1);
        }
    }
]
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 » 17 Aug 2013, 09:58

i need to use "otherPermanent.isBeast" in this code, and the crashlog shows that such property is not available, yet ? anyone can help with this? :)

Code: Select all
[
    new MagicWhenOtherComesIntoPlayTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
            return (otherPermanent.isCreature() && otherPermanent.isBeast) ?
                new MagicEvent(
                    permanent,
                    new MagicSimpleMayChoice(
                        MagicSimpleMayChoice.DRAW_CARDS,
                        1,
                        MagicSimpleMayChoice.DEFAULT_NONE
                    ),
                    this,
                    "PN may\$ draw a card."               
            ) :
                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

Re: Adding new cards with Groovy

Postby melvin » 17 Aug 2013, 10:04

Use otherPermanent.hasSubType(MagicSubType.Beast) instead, see https://code.google.com/p/magarena/sour ... ont.groovy
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 » 17 Aug 2013, 14:14

i have completed testing of "wirewood savage" card script, and has posted it to firemind.ch, when can i post a deck with it?
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 » 17 Aug 2013, 14:22

hong yie wrote:i have completed testing of "wirewood savage" card script, and has posted it to firemind.ch, when can i post a deck with it?
Thanks! You can post it anytime, but add a note that it is for the upcoming release of version 1.41.
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 » 18 Aug 2013, 03:27

drooone wrote:Does Magarena support the "Convoke" ability?
No, btw welcome to the forum, drooone :D

Thanks for submitting cards on firemind.ch, I've merged your Millennial Gargoyle and it will be part of the August release.
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 Aug 2013, 05:05

Image
ajani_s_chosen.txt
Code: Select all
name=Ajani's Chosen
url=http://magiccards.info/m14/en/2.html
image=http://magiccards.info/scans/en/m14/2.jpg
value=3.833
rarity=R
type=Creature
subtype=Cat,Soldier
cost={2}{W}{W}
pt=3/3
timing=fmain
requires_groovy_code
ajani_s_chosen.groovy
Code: Select all
[
    new MagicWhenOtherComesIntoPlayTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
            return (otherPermanent.isEnchantment() ) ?
                new MagicEvent(
                permanent,
                this,
                "PN puts a 2/2 white Cat creature token onto the battlefield."            
            ) :
                MagicEvent.NONE;
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
         game.doAction(new MagicPlayTokensAction(
            event.getPlayer(),
            TokenCardDefinitions.get("Cat2"), 1));
        }
    }
]
the groovy code for this card is almost finish, except the final word stating "If that enchantment is an Aura, you may attach it to the token." time to need some help, :)
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 Aug 2013, 09:35

tried to submit these to firemind.ch, it can't accept empty script for the token, so i will put it here first.
Image
Soldier_RW.txt
Code: Select all
name=Soldier RW
token=Soldier
image=http://media.wizards.com/images/magic/daily/arcana/1138_league_hm688e7km6.jpg
value=1
ability=haste
type=Creature
subtype=Soldier
color=rw
cost={0}
pt=1/1
Image
Assemble_the_Legion.txt
Code: Select all
name=Assemble the Legion
url=http://magiccards.info/gtc/en/142.html
image=http://magiccards.info/scans/en/gtc/142.jpg
value=3.687
rarity=R
type=Enchantment
cost={3}{R}{W}
timing=enchantment
requires_groovy_code
Assemble_the_Legion.groovy
Code: Select all
[
    new MagicAtUpkeepTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
            return permanent.isController(upkeepPlayer) ?
            new MagicEvent(
                permanent,
                this,
                "PN puts a muster counter on SN."
            ):
         MagicEvent.NONE;
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            game.doAction(new MagicChangeCountersAction(event.getPermanent(),MagicCounterType.Charge,1,true));
         final MagicPermanent source = event.getPermanent()
         final int amount = source.getCounters(MagicCounterType.Charge);
         game.doAction(new MagicPlayTokensAction(event.getPlayer(),TokenCardDefinitions.get("Soldier RW"), 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 melvin » 18 Aug 2013, 10:18

hong yie wrote:the groovy code for this card is almost finish, except the final word stating "If that enchantment is an Aura, you may attach it to the token." time to need some help, :)
Turns out it is not implementable as there is no way to attach an Aura after it enters the battlefield. I've fixed it by changing MagicAttachEquipmentAction to MagicAttachAction that also works for Auras. The complete version is as follows, it has been integrated into the development version of the game.

Magarena/scripts/Ajani_s_Chosen.groovy
Code: Select all
[
    new MagicWhenOtherComesIntoPlayTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
            return otherPermanent.isEnchantment() && otherPermanent.isFriend(permanent) ?
                new MagicEvent(
                    permanent,
                    otherPermanent,
                    this,
                    "PN puts a 2/2 white Cat creature token onto the battlefield."
                ):
                MagicEvent.NONE;
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            final MagicPlayTokenAction act = new MagicPlayTokenAction(
                event.getPlayer(),
                TokenCardDefinitions.get("Cat2")
            );
            game.doAction(act);
            final MagicPermanent token = act.getPermanent();
            final MagicPermanent enchantment = event.getRefPermanent();
            if (enchantment.isAura()) {
                game.addEvent(new MagicEvent(
                    enchantment,
                    new MagicMayChoice("Attach ${enchantment} to ${token}?"),
                    token,
                    {
                        final MagicGame G, final MagicEvent E ->
                        G.doAction(new MagicAttachAction(
                            E.getPermanent(),
                            E.getRefPermanent()
                        ));
                    } as MagicEventAction,
                    "You may\$ attach SN to RN."
                ));
            }
        }
    }
]
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 ember hauler » 18 Aug 2013, 12:54

Hi,

I made a Rusted Slasher card, but it has a strange behaviour.
This is the code:

Code: Select all
name=Rusted Slasher
url=http://magiccards.info/mbs/en/128.html
image=http://magiccards.info/scans/en/mbs/128.jpg
value=2.125
rarity=C
type=Artifact,Creature
subtype=Horror
cost={4}
pt=4/1
timing=main
requires_groovy_code
This is the Groovy script:

Code: Select all
[
    new MagicPermanentActivation(
        new MagicActivationHints(MagicTiming.Pump),
        "Regen"
    ) {
        @Override
        public MagicEvent[] getCostEvent(final MagicPermanent source) {
            return [
                new MagicSacrificePermanentEvent(
                    source,
                    MagicTargetChoice.SACRIFICE_ARTIFACT
                ),
                new MagicRegenerationConditionsEvent(source,this)
            ];
        }
        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
            return new MagicEvent(
                source,
                this,
                "Regenerate SN."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            game.doAction(new MagicRegenerateAction(event.getPermanent()));
        }
    }
]
It's based on Corrupted Harvester.

The card works fine, except Magarena doesn't offer to regenerate any copy on the battlefield except the first one.

Is this the card or the game problem?
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 » 18 Aug 2013, 13:11

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.

ember hauler wrote:The card works fine, except Magarena doesn't offer to regenerate any copy on the battlefield except the first one. Is this the card or the game problem?
It is a game problem, specially this issue https://code.google.com/p/magarena/issues/detail?id=379. It is fixed for next release.
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 » 18 Aug 2013, 13:55

Image

Magarena/scripts/Manaweft_Sliver.txt
Code: Select all
name=Manaweft Sliver
url=http://magiccards.info/m14/en/184.html
image=http://magiccards.info/scans/en/m14/184.jpg
value=2.70
rarity=U
type=Creature
subtype=Sliver
cost={1}{G}
pt=1/1
static=player
timing=main
requires_groovy_code
Magarena/scripts/Manaweft_Sliver.groovy
Code: Select all
def TapAddAny = new MagicTapManaActivation(MagicManaType.ALL_TYPES);

[
    new MagicStatic(
        MagicLayer.Ability,
        MagicTargetFilter.TARGET_SLIVER_YOU_CONTROL
    ) {
        @Override
        public void modAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final Set<MagicAbility> flags) {
            permanent.addAbility(TapAddAny);
        }
    }
]
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 » 18 Aug 2013, 13:57

Image

Magarena/scripts/Thorncaster_Sliver.txt
Code: Select all
name=Thorncaster Sliver
url=http://magiccards.info/m14/en/158.html
image=http://magiccards.info/scans/en/m14/158.jpg
value=2.70
rarity=R
type=Creature
subtype=Sliver
cost={4}{R}
pt=2/2
static=player
timing=main
requires_groovy_code
Magarena/scripts/Thorncaster_Sliver.groovy
Code: Select all
def AttacksPing = new MagicWhenAttacksTrigger() {
    @Override
    public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent creature) {
        return (permanent==creature) ?
            new MagicEvent(
                permanent,
                MagicTargetChoice.NEG_TARGET_CREATURE_OR_PLAYER,
                new MagicDamageTargetPicker(1),
                this,
                "SN deals 1 damage to target creature or player\$."
            ):
            MagicEvent.NONE;
    }
    @Override
    public void executeEvent(final MagicGame game, final MagicEvent event) {
        event.processTarget(game,new MagicTargetAction() {
            public void doAction(final MagicTarget target) {
                game.doAction(new MagicDealDamageAction(
                    new MagicDamage(
                        event.getPermanent(),
                        target,
                        1
                    )
                ));
            }
        });
    }
};

[
    new MagicStatic(
        MagicLayer.Ability,
        MagicTargetFilter.TARGET_SLIVER_YOU_CONTROL
    ) {
        @Override
        public void modAbilityFlags(final MagicPermanent source,final MagicPermanent permanent,final Set<MagicAbility> flags) {
            permanent.addAbility(AttacksPing);
        }
    }
]
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 15 guests


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 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 15 guests

Login Form