Page 18 of 28

Re: Adding new cards with Groovy

PostPosted: 16 Feb 2014, 14:13
by ShawnieBoy
Nice work :)

I don't think there's templates on Firemind for Born of the Gods

Re: Adding new cards with Groovy

PostPosted: 17 Feb 2014, 13:10
by melvin
Image

Magarena/scripts/Brimaz__King_of_Oreskos.txt
Code: Select all
name=Brimaz, King of Oreskos
url=http://magiccards.info/bng/en/5.html
image=http://mtgimage.com/card/brimaz%2C%20king%20of%20oreskos.jpg
value=3.741
rarity=M
type=Legendary,Creature
subtype=Cat,Soldier
cost={1}{W}{W}
ability=vigilance
pt=3/4
timing=main
requires_groovy_code
Magarena/scripts/Brimaz__King_of_Oreskos.groovy
Code: Select all
[
    new MagicWhenAttacksTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent attacker) {
            return permanent == attacker ?
                new MagicEvent(
                    permanent,
                    this,
                    "PN puts a 1/1 white Cat Soldier creature token with vigilance onto the battlefield attacking."
                ) :
                MagicEvent.NONE;
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            final MagicPlayer player=event.getPlayer();
            game.doAction(new MagicPlayCardAction(
                MagicCard.createTokenCard(
                    TokenCardDefinitions.get("1/1 white Cat Soldier creature token with vigilance"),
                    player
                ),
                player,
                [MagicPlayMod.ATTACKING]
            ));
        }
    },
    new MagicWhenBlocksTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent blocker) {
            final MagicPermanent blocked = permanent.getBlockedCreature();
            return (permanent == blocker && blocked.isValid()) ?
                new MagicEvent(
                    permanent,
                    blocked,
                    this,
                    "PN puts a 1/1 white Cat Soldier creature token with vigilance onto the battlefield blocking RN."
                ):
                MagicEvent.NONE;
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            final MagicPlayer player=event.getPlayer();
            final MagicPlayCardAction act = new MagicPlayCardAction(
                MagicCard.createTokenCard(
                    TokenCardDefinitions.get("1/1 white Cat Soldier creature token with vigilance"),
                    player
                ),
                player
            );
            game.doAction(act);
            game.doAction(new MagicSetBlockerAction(event.getRefPermanent(), act.getPermanent()));
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 17 Feb 2014, 22:17
by ShawnieBoy
I've tried making Feast of Blood using MagicCardActivation conditions, and I must be doing something wrong as it is coming into play as a permanent, and not creating any effects:

Code: Select all
name=Feast of Blood
url=http://magiccards.info/zen/en/88.html
image=http://mtgimage.com/card/feast%20of%20blood.jpg
value=4.013
rarity=U
type=Sorcery
cost={1}{B}
timing=main
requires_groovy_code
Code: Select all
def TWO_OR_MORE_VAMPIRES_CONDITION = new MagicCondition() {
        public boolean accept(final MagicSource source) {
            return source.getController().getNrOfPermanents(MagicSubType.Vampire)>=2;
        }
    };

[
    new MagicCardActivation(
        [TWO_OR_MORE_VAMPIRES_CONDITION],
        new MagicActivationHints(MagicTiming.Removal,true),
        "Destroy"
        ) {
        @Override
        public Iterable<MagicEvent> getCostEvent(final MagicCard source) {
            return source.getCostEvent();
        }
        @Override
        public MagicEvent getEvent(final MagicCardOnStack cardOnStack, final MagicPayedCost payedCost) {
            return new MagicEvent(
                cardOnStack,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                MagicDestroyTargetPicker.Destroy,
                this,
                "Destroy target creature\$. " +
                "PN gains 4 life."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTargetPermanent(game, {
                final MagicPermanent creature ->
                game.doAction(new MagicDestroyAction(creature));
                game.doAction(new MagicChangeLifeAction(event.getPlayer(),4));
            });
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 18 Feb 2014, 05:33
by melvin
Currently there is no way to replace the default MagicCardActivation. I've just pushed a change that makes this possible in https://code.google.com/p/magarena/sour ... 1b865eec87

With this new method, the new MagicCardActivation should be written as follows:
The difference is the addition of the change method that calls the new setCardAct method. The getCostEvent method is redundant as it is the same as that provided by MagicCardActivation, I've removed it from the code below.
Code: Select all
    new MagicCardActivation(
        [TWO_OR_MORE_VAMPIRES_CONDITION],
        new MagicActivationHints(MagicTiming.Removal,true),
        "Destroy"
    ) {
        @Override
        public void change(final MagicCardDefinition cdef) {
            cdef.setCardAct(this);
        }
        @Override
        public MagicEvent getEvent(final MagicCardOnStack cardOnStack, final MagicPayedCost payedCost) {
            return new MagicEvent(
                cardOnStack,
                MagicTargetChoice.NEG_TARGET_CREATURE,
                MagicDestroyTargetPicker.Destroy,
                this,
                "Destroy target creature\$. " +
                "PN gains 4 life."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTargetPermanent(game, {
                final MagicPermanent creature ->
                game.doAction(new MagicDestroyAction(creature));
                game.doAction(new MagicChangeLifeAction(event.getPlayer(),4));
            });
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 18 Feb 2014, 05:44
by ShawnieBoy
That's great news! Thanks for that - Conditional spells ahoy ;)

Re: Adding new cards with Groovy

PostPosted: 18 Feb 2014, 05:52
by melvin
Just found a bug, should add MagicCondition.CARD_CONDITION to the MagicCardActivation for Feast of Blood so that it follows the Sorcery type restriction

Re: Adding new cards with Groovy

PostPosted: 19 Feb 2014, 21:13
by mike
hong yie wrote:tried to submit this script to firemind.ch, but somehow this card is not recognized. i think this would be in Mike's Authority, maybe.
Anyway here it is
Sorry guys, just now gotten around to adding the BNG cards to firemind.ch

Re: Adding new cards with Groovy

PostPosted: 25 Feb 2014, 05:24
by melvin
mike wrote:Sorry guys, just now gotten around to adding the BNG cards to firemind.ch
Thanks, mike :)

While watching the finals of PTBNG, I thought of a way we can encode phyrexian mana cards! Here is the first one.

Image

Magarena/scripts/Mental_Misstep.txt
Code: Select all
name=Mental Misstep
url=http://magiccards.info/nph/en/38.html
image=http://mtgimage.com/card/mental%20misstep.jpg
value=4.626
rarity=U
type=Instant
cost={U}
effect=Counter target spell with converted mana cost 1.
timing=counter
requires_groovy_code
Magarena/scripts/Mental_Misstep.groovy
Code: Select all
[
    new MagicCardActivation(
        [MagicCondition.CARD_CONDITION],
        new MagicActivationHints(MagicTiming.Counter,true),
        "Pay 2 life"
    ) {
        public Iterable<MagicEvent> getCostEvent(final MagicCard source) {
            return [
                new MagicPayLifeEvent(source, 2)
            ];
        }
    }
]

Re: Adding new cards with Groovy

PostPosted: 25 Feb 2014, 06:28
by ShawnieBoy
Nice - is it possible to add normal mana activations into the Alternate costs? For {3} {RP} {RP}, Act of Aggression for example? (Well, several alternate costs: {3} {R} +2 life, {3} +4 life)

Re: Adding new cards with Groovy

PostPosted: 25 Feb 2014, 07:06
by melvin
Sure, just add two MagicCardActivation with the respective costs.

For example,
Code: Select all
return [         
   new MagicPayManaCostEvent(source,"{3}{R}")
   new MagicPayLifeEvent(source, 2)                                                                                                                                             
];

Re: Adding new cards with Groovy

PostPosted: 25 Feb 2014, 16:30
by ShawnieBoy
This is so cool :)

Hopefully there's a way to stitch this onto the MagicPayManaCostChoice and the MagicBuilderManaCost-type engine. I've had a look at the mana generation prompting but doesn't make a lot of sense to me. Would be good to have a choice prompt for Phyrexian mana while paying mana instead of when casting.

Choose a method to may {P/U}:
[{U}] [Pay 2 life]

then if the mana choice is chosen, it leads to the normal mana prompt:

Choose a mana source to pay {U}

Otherwise the life is paid.

Re: Adding new cards with Groovy

PostPosted: 26 Feb 2014, 01:51
by melvin
Agree, originally I've been thinking along these lines, but the generation of different ways to pay mana for the AI is already quite complicated. Hacking it to tack on paying life would make it even more complex.

Hence the thought of using separate activation, which keeps it away from the core engine and can be done in the card itself using groovy code. Unless phyrexian mana becomes a regular thing (which I highly doubt since its flavor is tied to Phyrexia) it doesn't make sense to complicate the core to support it.

I'm looking at one more step to simplify it by providing syntax to specify alternative casting cost as a card ability. Then we can use our regular cost parsing to do the heavy lifting and do the work in the card script instead of in groovy code.

Re: Adding new cards with Groovy

PostPosted: 26 Feb 2014, 03:01
by ShawnieBoy
Cool - The only reason I wondered, is for permanents with activation costs using Phyrexian mana. We'll end up with having multiple activations with the same hint, as the hints on permanents relate to the effects, not how payment will be payed.

Insatiable Souleater, for example, would have ability hints of [Trample] [Trample] with no way to tell the difference.

Re: Adding new cards with Groovy

PostPosted: 26 Feb 2014, 03:15
by melvin
We should give a different name to indicate payment of life, perhaps say "Phyrexian Trample". Not sure if it will fit on the dialog UI though.

Re: Adding new cards with Groovy

PostPosted: 26 Feb 2014, 16:07
by ShawnieBoy
As the UI buttons can accept the mana symbols - maybe a symbol to represent payment of life. So Birthing Pod would have hints of: [ {G} :Search] [ {2Life} :Search] - Omitting the {1}, {T} and 'Sacrifice a creature' as they appear on both?