Page 9 of 25

Re: Card Contributions

PostPosted: 05 Apr 2014, 16:46
by frank
run into another question.
Xenagos, God of Revels awards +X/+X until end of turn to another creature.
I got the card implemented, and it works so far except I can't find a way to exclude him from his own ability targeting.

I saw you using the the word "other" in card definitions... so how is that done in groovy?

Code: Select all
name=Xenagos, God of Revels
url=http://magiccards.info/query?q=%21xenagos%2C%20god%20of%20revels
image=http://mtgimage.com/card/xenagos%2C%20god%20of%20revels.jpg
value=3.863
rarity=M
type=Legendary,Enchantment,Creature
subtype=God
cost={3}{R}{G}
pt=6/5
ability=indestructible
timing=main
requires_groovy_code
groovy:
Code: Select all
[
    new MagicStatic(MagicLayer.Type) {
        @Override
        public int getTypeFlags(final MagicPermanent permanent,final int flags) {
            return flags & ~MagicType.Creature.getMask();
        }
        @Override
        public void modSubTypeFlags(final MagicPermanent permanent,final Set<MagicSubType> flags) {
            flags.remove(MagicSubType.God);
        }
        @Override
        public boolean condition(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
            return source.getController().getDevotion(MagicColor.Green, MagicColor.Red) < 7;
        }
    },
    new MagicAtBeginOfCombatTrigger() {
               
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer attackingPlayer) {
            return permanent.getController() == attackingPlayer ? new MagicEvent(
                permanent,
                new MagicTargetChoice("target creature you control"),
                MagicPumpTargetPicker.create(),
                this,
                "Another target creature\$ you control gains haste and gets +X/+X until end of turn, where X is that creature's power."
            ):MagicEvent.NONE;
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTargetPermanent(game, {
                final MagicPermanent perm ->
                game.doAction(new MagicAddStaticAction(perm, new MagicStatic(MagicLayer.ModPT,MagicStatic.UntilEOT) {
                    @Override
                    public void modPowerToughness(final MagicPermanent source,final MagicPermanent permanent,final MagicPowerToughness pt) {
                        pt.add(permanent.getPower(),permanent.getPower());
                    }
                }));
            });
         
        }
    }
]
edit: and yet another question:
Whip of Erebos is a Corpse Dance on demand, so to say, except it adds an extra ability to the reanimated creature - if that creature would leave play in any case exile it.

The card works fine so far, except, that the given ability ExileAtLeaving wouldn't trigger. And the timing (sorcery) needs yet to be implemented. Any idea how to fix this?

Whip of Erebos:
Code: Select all
name=Whip of Erebos
url=http://magiccards.info/query?q=%21whip%20of%20erebos
image=http://mtgimage.com/card/whip%20of%20erebos.jpg
value=3.511
rarity=R
type=Legendary,Enchantment,Artifact
cost={2}{B}{B}
ability=lord Creatures you control have lifelink
timing=artifact
requires_groovy_code
groovy:
Code: Select all
def ExileAtLeaving = new MagicWhenLeavesPlayTrigger(){
   @Override
   public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicRemoveFromPlayAction act) {
       return act.isPermanent(permanent)? new MagicExileEvent(permanent) : MagicEvent.NONE;
   }
};
[
    new MagicPermanentActivation(new MagicActivationHints(MagicTiming.Animate),"Animate"){
        @Override
        public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
            return [
                new MagicTapEvent(source),
                new MagicPayManaCostEvent(source,"{2}{B}{B}")
            ];
        }
        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
            return new MagicEvent(
                source,
                MagicTargetChoice.TARGET_CREATURE_CARD_FROM_GRAVEYARD,
                MagicGraveyardTargetPicker.PutOntoBattlefield,
                this,
                "Return target creature card\$ from your graveyard to the battlefield. "+
                "It gains haste. Exile it at the beginning of the next end step. "+
                "If it would leave the battlefield, exile it instead of putting it anywhere else."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.processTargetCard(game, {
                final MagicCard targetCard ->
                game.doAction(new MagicRemoveCardAction(targetCard,MagicLocationType.Graveyard));
                final MagicPlayCardAction action = new MagicPlayCardAction(targetCard,event.getPlayer());
                game.doAction(action);
                final MagicPermanent permanent = action.getPermanent();
                game.doAction(new MagicGainAbilityAction(permanent,MagicAbility.Haste,MagicStatic.UntilEOT));
                game.doAction(new MagicGainAbilityAction(permanent,MagicAbility.ExileAtEnd,MagicStatic.UntilEOT));
                permanent.addAbility(ExileAtLeaving);
            });
        }
    }
]

Re: Card Contributions

PostPosted: 06 Apr 2014, 01:03
by melvin
For 'other' a custom filter is needed beacause you need to pass in the permanent that should not be the target, so instead of
Code: Select all
new MagicTargetChoice("target creature you control")
it should be
Code: Select all
new MagicTargetChoice(
     MagicOtherPermanentTargetFilter(MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL, permanent),
     "another target creature you control"
)
In the second case, directly modifying a permanent is not recommended, an 'action' should be used. This allows for proper undo management. Instead of
Code: Select all
permanent.addAbility(ExileAtLeaving);
use
Code: Select all
game.doAction(new MagicAddTriggerAction(permannet, ExileAtLeaving)
ExileAtLeaving shouldn't be using the MagicExileEvent as the permanent has already left the battlefield, the correct implementation should be similar to Rest_in_Peace.groovy, with the addition of the act.isPermanent(permanent) check.

For sorcery condition, add [MagicCondition.SORCERY_CONDITION] when creating the MagicPermanentActivation. The condition should be given before the hint.

Re: Card Contributions

PostPosted: 06 Apr 2014, 17:56
by frank
say, is it possible to code "can't have or gain Ability". If yes, how?

Re: Card Contributions

PostPosted: 07 Apr 2014, 02:07
by melvin
frank wrote:say, is it possible to code "can't have or gain Ability". If yes, how?
No. Is this for the archetypes?

Re: Card Contributions

PostPosted: 07 Apr 2014, 07:05
by frank
yes, the five archetypes

Re: Card Contributions

PostPosted: 07 Apr 2014, 21:59
by ShawnieBoy
Another set of rules with ability effecting abilities would be the 'can <something> as though it/they didn't have <ability>'

Essentially turning off the functionality of an ability without removing the flags that say they have it. Almost the opposite of the Archetypes.

Cards like: Glaring Spotlight, Colossus of Akros, Crevasse

Re: Card Contributions

PostPosted: 08 Apr 2014, 01:06
by frank
another Question: if I had an ArrayList<MagicTarget> how would I cast or transmute or somehow alter it into a MagicTargetFilter? Help? Anybody?

or even better - how would I get a MagicTargetChoice to work with said ArrayList?

Re: Card Contributions

PostPosted: 08 Apr 2014, 01:48
by ShawnieBoy
Why need an ArrayList? A FilterFactory could probably do the same thing. What are you trying to target?

Re: Card Contributions

PostPosted: 08 Apr 2014, 05:50
by frank
a given MagicCardList, provided by such as permanent.getExiledCards() for example


edit:
well, things change, I tried another approach, and it worked out. I don't need an answer anymore. Thanks anyway ;)

Re: Card Contributions

PostPosted: 19 Jun 2014, 23:01
by ShawnieBoy
I don't know if midnight is the best time to start working on Remove Enchantments
Wish me luck :shock:

Re: Card Contributions

PostPosted: 01 Jul 2014, 17:30
by jerichopumpkin
It's been a while sice I scripted something, so I'm totally amazed by how quick was to put this togheter with all the new features...
Four months ago, it would have been a pain just to find the right groovy code to modify, and now, no groovy, a perfect fit found in no time with the card explorer! Great job guys, keep rocking!!!

Image

sporesower_thallid.txt
Code: Select all
name=Sporesower Thallid
image=http://mtgimage.com/card/sporesower%20thallid.jpg
value=3.981
rarity=U
type=Creature
subtype=Fungus
cost={2}{G}{G}
pt=4/4
ability=At the beginning of your upkeep, put a spore counter on each Fungus creature you control.;\
        Remove three spore counters from SN: Put a 1/1 green Saproling creature token onto the battlefield.
timing=main
oracle=At the beginning of your upkeep, put a spore counter on each Fungus you control. Remove three spore counters from Sporesower Thallid: Put a 1/1 green Saproling creature token onto the battlefield.

Re: Card Contributions

PostPosted: 01 Jul 2014, 20:44
by ShawnieBoy
jerichopumpkin wrote:It's been a while sice I scripted something, so I'm totally amazed by how quick was to put this togheter with all the new features...
Four months ago, it would have been a pain just to find the right groovy code to modify, and now, no groovy, a perfect fit found in no time with the card explorer! Great job guys, keep rocking!!!

sporesower_thallid.txt
Code: Select all
name=Sporesower Thallid
image=http://mtgimage.com/card/sporesower%20thallid.jpg
value=3.981
rarity=U
type=Creature
subtype=Fungus
cost={2}{G}{G}
pt=4/4
ability=At the beginning of your upkeep, put a spore counter on each Fungus creature you control.;\
        Remove three spore counters from SN: Put a 1/1 green Saproling creature token onto the battlefield.
timing=main
oracle=At the beginning of your upkeep, put a spore counter on each Fungus you control. Remove three spore counters from Sporesower Thallid: Put a 1/1 green Saproling creature token onto the battlefield.
Glad you've found it so easy :D - It's even easier seeing as this file can be found as-is in the Magarena\scripts_missing folder. Just need to move it into the Magarena\scripts folder!

There's plenty more hiding in there to be found, I'm always surprised to find a fully functioning card just sat there waiting for me :D

Re: Card Contributions

PostPosted: 03 Jul 2014, 23:59
by ShawnieBoy
You can also move over Deathbringer Thoctar and Dictate of Erebos - Two cards that already work and also work nicely together :)

Along with a themed pair: Rotting Rats and Rix Maadi, Dungeon Palace (Although the Palace just needs an addition of {Sorcery} to the mana cost and remove the 'Activate this only as a sorcery')

Re: Card Contributions

PostPosted: 06 Jul 2014, 18:45
by ShawnieBoy
Another bunch of cards that can be moved from Magarena\scripts_missing to Magarena\scripts:

Jackalope Herd, Ashiok's Adept and Skittering Monstrosity

Re: Card Contributions

PostPosted: 07 Jul 2014, 21:44
by jerichopumpkin
Can't submit to Firemind:
Image
Dack_s_Duplicate.txt
Code: Select all
name=Dack's Duplicate
image=http://mtgimage.com/card/dack%27s%20duplicate.jpg
value=2.500
rarity=R
type=Creature
subtype=Shapeshifter
cost={2}{U}{R}
pt=0/0
timing=main
requires_groovy_code
oracle=You may have Dack's Duplicate enter the battlefield as a copy of any creature on the battlefield except it gains haste and dethrone.
Dack_s_Duplicate.groovy
Code: Select all
[
    new MagicSpellCardEvent() {
        @Override
        public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
            return new MagicEvent(
                cardOnStack,
                new MagicMayChoice(MagicTargetChoice.CREATURE),
                MagicCopyPermanentPicker.create(),
                this,
                "Put SN onto the battlefield. You may\$ have SN enter the battlefield as a copy of any creature\$ on the battlefield, except it gains haste and dethrone."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            if (event.isYes()) {
                event.processTargetPermanent(game, {
                    final MagicPermanent chosen ->
                    final MagicPlayCardFromStackAction action = MagicPlayCardFromStackAction.EnterAsCopy(
                        event.getCardOnStack(),
                        chosen
                    );
                    game.doAction(action);
                    final MagicPermanent permanent = action.getPermanent();
                    game.doAction(new MagicGainAbilityAction(permanent,MagicAbility.Haste, MagicStatic.Forever));
               game.doAction(new MagicGainAbilityAction(permanent,MagicAbility.Dethrone, MagicStatic.Forever));

                });
            } else {
                game.doAction(new MagicPlayCardFromStackAction(
                    event.getCardOnStack()
                ));
            }
        }
    }
]