Card Contributions
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Card Contributions
by frank » 05 Apr 2014, 16:46
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?
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:
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
- 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());
}
}));
});
}
}
]
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
- 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
by melvin » 06 Apr 2014, 01:03
For 'other' a custom filter is needed beacause you need to pass in the permanent that should not be the target, so instead of
For sorcery condition, add [MagicCondition.SORCERY_CONDITION] when creating the MagicPermanentActivation. The condition should be given before the hint.
- Code: Select all
new MagicTargetChoice("target creature you control")
- Code: Select all
new MagicTargetChoice(
MagicOtherPermanentTargetFilter(MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL, permanent),
"another target creature you control"
)
- Code: Select all
permanent.addAbility(ExileAtLeaving);
- Code: Select all
game.doAction(new MagicAddTriggerAction(permannet, ExileAtLeaving)
For sorcery condition, add [MagicCondition.SORCERY_CONDITION] when creating the MagicPermanentActivation. The condition should be given before the hint.
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by frank » 06 Apr 2014, 17:56
say, is it possible to code "can't have or gain Ability". If yes, how?
Re: Card Contributions
by melvin » 07 Apr 2014, 02:07
No. Is this for the archetypes?frank wrote:say, is it possible to code "can't have or gain Ability". If yes, how?
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by ShawnieBoy » 07 Apr 2014, 21:59
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
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
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by frank » 08 Apr 2014, 01:06
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?
or even better - how would I get a MagicTargetChoice to work with said ArrayList?
Re: Card Contributions
by ShawnieBoy » 08 Apr 2014, 01:48
Why need an ArrayList? A FilterFactory could probably do the same thing. What are you trying to target?
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by frank » 08 Apr 2014, 05:50
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
edit:
well, things change, I tried another approach, and it worked out. I don't need an answer anymore. Thanks anyway

Re: Card Contributions
by ShawnieBoy » 19 Jun 2014, 23:01
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by jerichopumpkin » 01 Jul 2014, 17:30
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
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.
- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Re: Card Contributions
by ShawnieBoy » 01 Jul 2014, 20:44
Glad you've found it so easyjerichopumpkin 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.

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

-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by ShawnieBoy » 03 Jul 2014, 23:59
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')

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')
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by ShawnieBoy » 06 Jul 2014, 18:45
Another bunch of cards that can be moved from Magarena\scripts_missing to Magarena\scripts:
Jackalope Herd, Ashiok's Adept and Skittering Monstrosity
Jackalope Herd, Ashiok's Adept and Skittering Monstrosity
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by jerichopumpkin » 07 Jul 2014, 21:44
Can't submit to Firemind:

Dack_s_Duplicate.txt

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.
- 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()
));
}
}
}
]
- jerichopumpkin
- Posts: 212
- Joined: 12 Sep 2013, 11:21
- Has thanked: 19 times
- Been thanked: 13 times
Who is online
Users browsing this forum: No registered users and 1 guest