Adding new cards with Groovy
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Adding new cards with Groovy
by hong yie » 24 Apr 2014, 00:58
Alabaster_Dragon.txt
i hope this script do the trick.
- Code: Select all
name=Alabaster Dragon
url=http://magiccards.info/wl/en/.html
image=http://magiccards.info/scans/en/wl/.jpg
value=3.269
rarity=R
type=Creature
subtype=Dragon
cost={4}{W}{W}
pt=4/4
ability=flying;\
When SN dies, shuffle it into its owner's library.
timing=main
i hope this script do the trick.

-
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
by ShawnieBoy » 24 Apr 2014, 13:45
Ok, I get the hint - I've enabled shuffling permanents into the library via 'shuffle SN into its owner's library' with scripts. May take a little longer to push as I'm also looking at letting cards know where they arehong yie wrote:Alabaster_Dragon.txtUpdated ability trigger
- Code: Select all
name=Alabaster Dragon
url=http://magiccards.info/wl/en/.html
image=http://magiccards.info/scans/en/wl/.jpg
value=3.269
rarity=R
type=Creature
subtype=Dragon
cost={4}{W}{W}
pt=4/4
ability=flying;\
When SN dies, shuffle it into its owner's library.
timing=main
i hope this script do the trick.

-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 02 May 2014, 05:35
correction on Reveillark txt code.
Reveillark.txt
Reveillark.txt
- Code: Select all
name=Reveillark
url=http://magiccards.info/mma/en/26.html
image=http://magiccards.info/scans/en/mma/26.jpg
value=4.241
rarity=R
type=Creature
subtype=Elemental
cost={4}{W}
pt=4/3
ability=flying;evoke {5}{W}
timing=main
requires_groovy_code
-
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
by melvin » 02 May 2014, 08:31
Thanks for the fix, applied in https://code.google.com/p/magarena/sour ... f674209974
-
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
by hong yie » 03 May 2014, 16:17
i checked the fix, the evoke cost still not corrected.melvin wrote:Thanks for the fix, applied in https://code.google.com/p/magarena/sour ... f674209974

-
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
by ShawnieBoy » 03 May 2014, 20:54
I've submitted the 'fix' for Reveillark but it's still going to be in the incomplete folder as it involves multiple targets (and an 'up to' target as well) and there's currently no function for the AI to perform that, as the options are 0, 1 or 2 as well as the main 'may' choice.
I'd like the incomplete folder to be more than just a 'dumping-ground', I do like the reference of a '(nearly) OK Corral' - thanks Frank
Seeing what other people have been trying/working on/need help with can allow a more collaborative feel, than single people working on individual cards.
As always, getting one card to work will usually open the gates for a few more
https://code.google.com/p/magarena/sour ... incomplete
Some may be more stubborn than others but these cards can always return to the herd
I'd like the incomplete folder to be more than just a 'dumping-ground', I do like the reference of a '(nearly) OK Corral' - thanks Frank

As always, getting one card to work will usually open the gates for a few more

https://code.google.com/p/magarena/sour ... incomplete
Some may be more stubborn than others but these cards can always return to the herd

-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 05 May 2014, 22:06
i tried this code, but the X damage is not dealt.
i wonder which part is wrong here?
Nin__the_Pain_Artist.groovy
i wonder which part is wrong here?
Nin__the_Pain_Artist.groovy
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public Iterable getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{X}{U}{R}"),
new MagicTapEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
final int amount=payedCost.getX();
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE,
new MagicDamageTargetPicker(1),
this,
"SN deals X damage to target creature. That creature's controller draws X cards."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
final int amount = event.getRefInt();
final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
game.doAction(new MagicDealDamageAction(damage));
game.doAction(new MagicDrawAction(target.getController(),amount));
}
});
}
}
]
-
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
by ShawnieBoy » 06 May 2014, 00:11
The event.getRefInt() hasn't been defined in the event.hong yie wrote:i tried this code, but the X damage is not dealt.
i wonder which part is wrong here?
Nin__the_Pain_Artist.groovy
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public Iterable getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{X}{U}{R}"),
new MagicTapEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
final int amount=payedCost.getX();
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE,
new MagicDamageTargetPicker(1),
this,
"SN deals X damage to target creature. That creature's controller draws X cards."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
final int amount = event.getRefInt();
final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
game.doAction(new MagicDealDamageAction(damage));
game.doAction(new MagicDrawAction(target.getController(),amount));
}
});
}
}
]
- Code: Select all
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE,
new MagicDamageTargetPicker(amount),
amount,
this,
"SN deals X damage to target creature. That creature's controller draws X cards."
);
- Code: Select all
final int amount = event.getCardOnStack().getX();
final MagicDamage damage=new MagicDamage(event.getSource(),target,amount);
game.doAction(new MagicDealDamageAction(damage));
game.doAction(new MagicDrawAction(target.getController(),amount));
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public Iterable getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{X}{U}{R}"),
new MagicTapEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
final int amount=payedCost.getX();
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE,
new MagicDamageTargetPicker(amount),
this,
"SN deals X damage to target creature. That creature's controller draws X cards."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
final MagicPermanent creature ->
final int amount = event.getCardOnStack().getX();
final MagicDamage damage=new MagicDamage(event.getSource(),creature,amount);
game.doAction(new MagicDealDamageAction(damage));
game.doAction(new MagicDrawAction(creature.getController(),amount));
});
}
}
]
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 06 May 2014, 00:39
thanx, for the fix, shawnie
putting it to test...
putting it to test...

-
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
by hong yie » 09 May 2014, 22:29
i tried the script from shawnie.
i got crash when starting the game.
i got crash when starting the game.
- Code: Select all
1 error
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at javax.swing.SwingWorker.get(Unknown Source)
at magic.ui.screen.DuelGameScreen$1.done(DuelGameScreen.java:44)
... 20 more
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\Games\Magarena-1.35\Magarena\scripts\Nin__the_Pain_Artist.groovy: 30: unexpected token: creature @ line 30, column 26.
- Code: Select all
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTarget(game,new MagicTargetAction() {
final MagicPermanent creature -> final int amount = event.getCardOnStack().getX();
final MagicDamage damage=new MagicDamage(event.getSource(),creature,amount);
game.doAction(new MagicDealDamageAction(damage));
game.doAction(new MagicDrawAction(creature.getController(),amount));
});
}
}
-
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
by ShawnieBoy » 09 May 2014, 23:08
Whoops, yes, made a bit of a mess on that one. This -really- should work:
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Damage"
) {
@Override
public Iterable getCostEvent(final MagicPermanent source) {
return [
new MagicPayManaCostEvent(source,"{X}{U}{R}"),
new MagicTapEvent(source)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
final int amount=payedCost.getX();
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_CREATURE,
new MagicDamageTargetPicker(amount),
amount,
this,
"SN deals "+amount+" damage to target creature. That creature's controller draws "+amount+" cards."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.processTargetPermanent(game, {
final MagicPermanent creature ->
final int amount = event.getRefInt();
final MagicDamage damage=new MagicDamage(event.getSource(),creature,amount);
game.doAction(new MagicDealDamageAction(damage));
game.doAction(new MagicDrawAction(creature.getController(),amount));
});
}
}
]
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 10 May 2014, 15:08
the script seemed to work,
i know it work when i try it on lethal damage. but i can't see the damage sign dealt by "nin" when the target survive, not because prevented, just not enough damage.
every damage dealt will leave red mark right ? this kinda confusing when the damage is not lethal, need to know amount of damage to finish the creature.
i know it work when i try it on lethal damage. but i can't see the damage sign dealt by "nin" when the target survive, not because prevented, just not enough damage.
every damage dealt will leave red mark right ? this kinda confusing when the damage is not lethal, need to know amount of damage to finish the creature.
-
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
by ShawnieBoy » 10 May 2014, 15:15
I'm having no issue with that - do you have a card you can cast in hand or activate on the battlefield as the damage will wear off when the turn automatically skips to the end of turn.
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Adding new cards with Groovy
by hong yie » 11 May 2014, 05:53
will test it some more.ShawnieBoy wrote:I'm having no issue with that - do you have a card you can cast in hand or activate on the battlefield as the damage will wear off when the turn automatically skips to the end of turn.
it could be skipped as you said.
-
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
by hong yie » 11 May 2014, 16:56
i try to script "Abyssal Persecutor" from "Platinum Angel"
just added a "!" after if. i'm putting it to test, just wonder will this work?
just added a "!" after if. i'm putting it to test, just wonder will this work?
- Code: Select all
[
new MagicIfPlayerWouldLoseTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicLoseGameAction loseAct) {
if !(permanent.isController(loseAct.getPlayer())) {
loseAct.setPlayer(MagicPlayer.NONE);
}
return MagicEvent.NONE;
}
}
]
-
hong yie - Programmer
- Posts: 216
- Joined: 10 Mar 2013, 06:44
- Location: Jakarta
- Has thanked: 75 times
- Been thanked: 9 times
Who is online
Users browsing this forum: No registered users and 15 guests