Adding new cards with Groovy
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Adding new cards with Groovy
by melvin » 10 Dec 2013, 06:31
Discard does not support restrictions on the card at this point. Should not be too hard to add it, will update the issue as more progress is made.
-
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 ShawnieBoy » 12 Dec 2013, 15:23
I know this isn't a proper Groovy question, but hopefully someone more Groovy than me can help.
I'm having some problems with the 'lord other' ability. It's scripted on Goblin King and others with no groovy (lord other Goblin creatures, lord other Black creatures etc.) - However trying to use (lord other creatures/other creatures you control) throws a bug.
The MagicTargetFilterFactory lord section doesn't throw much light, as there's no reference to 'other'. MagicTargetFilter does have a MagicOtherCardTargetFilter class but I'm unsure of how it fits with scripting.
I'm guessing it needs a specific creature-type or other defining filter. Any ideas?
I'm having some problems with the 'lord other' ability. It's scripted on Goblin King and others with no groovy (lord other Goblin creatures, lord other Black creatures etc.) - However trying to use (lord other creatures/other creatures you control) throws a bug.
The MagicTargetFilterFactory lord section doesn't throw much light, as there's no reference to 'other'. MagicTargetFilter does have a MagicOtherCardTargetFilter class but I'm unsure of how it fits with scripting.
I'm guessing it needs a specific creature-type or other defining filter. Any ideas?
-
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 melvin » 13 Dec 2013, 02:40
"lord other creatures you control" is used by scripts such as Veteran_Armorer.txt, and Sublime_Archangel.txt so it should work fine.
"lord other creatures" doesn't work since we didn't consider this case as no card uses it (yet), what would work is "lord other all creatures". 1.45 will allow "lord other creatures" to work.
"lord other creatures" doesn't work since we didn't consider this case as no card uses it (yet), what would work is "lord other all creatures". 1.45 will allow "lord other creatures" to work.
-
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 ShawnieBoy » 13 Dec 2013, 18:14
Ahh thanks - Festercreep was the card I had in mind - Didn't see lord other all creatures, was debating doing separate 'lord other creatures you control' and 'lord creatures your opponents control'.
-
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 melvin » 14 Dec 2013, 00:36
Do note that there is a slight difference between the lord ability and the effect of Festercreep.
The "lord" is a static ability generates a continuous effect that will also affect creatures that come onto the battlefield after the effect begins.
The effect in Festercreep is a continous effect generated by resolution of spell or ability, the set of creatures it affects is determined when the effect begins. A creature that comes onto the battlefield after the effect begins is NOT affected.
The "lord" is a static ability generates a continuous effect that will also affect creatures that come onto the battlefield after the effect begins.
The effect in Festercreep is a continous effect generated by resolution of spell or ability, the set of creatures it affects is determined when the effect begins. A creature that comes onto the battlefield after the effect begins is NOT affected.
-
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 ShawnieBoy » 26 Dec 2013, 22:19
First of all Happy Holidays 
I'm scratching my head over how to possibly implement the 'search for a copy of this card' type effect, found in Assembly Hall, Clarion Ultimatum, Infernal Tutor and Remembrance.
It's essentially trying to implement a custom filter for the search within an event, as the name cannot be defined prior (As in the groovy for Llanowar Sentinel)

I'm scratching my head over how to possibly implement the 'search for a copy of this card' type effect, found in Assembly Hall, Clarion Ultimatum, Infernal Tutor and Remembrance.
It's essentially trying to implement a custom filter for the search within an event, as the name cannot be defined prior (As in the groovy for Llanowar Sentinel)
- Code: Select all
game.addEvent(new MagicSearchIntoHandEvent(
event,
new MagicTargetChoice(
new MagicCardFilterImpl() {
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicCard target) {
return target.getName().equals(event.getRefCard().getName());
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Library;
}
},
"a card named RN"
)
));
- Code: Select all
event.getRefCard().getName()
-
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 melvin » 27 Dec 2013, 01:51
The fragment looks alright by itself, but it is hard to tell without seeing the full groovy script. Whether event.getRefCard() would work depends on how the event object was constructed earlier in the "new MagicEvent(...)" part. Specially it depends on whether the card you want to refer to is passed to the new MagicEvent.
Do include the full groovy script here.
When you say is doesn't really work, does it mean the card doesn't even load? Or it crashes when you try to play the card?
Do include the full groovy script here.
When you say is doesn't really work, does it mean the card doesn't even load? Or it crashes when you try to play the card?
-
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 » 27 Dec 2013, 03:01
i hope this new lord ability will be available.it could be fun. 
btw, if i want to look the code of all lord ability in "source", where should i look? can i try to add more lord ability too?

- Code: Select all
name=Blazing Archon
url=http://magiccards.info/pd3/en/11.html
image=http://magiccards.info/scans/en/pd3/11.jpg
value=4.411
rarity=R
type=Creature
subtype=Archon
cost={6}{W}{W}{W}
pt=5/6
ability=flying; lord opponent creatures have can't attack
timing=main
btw, if i want to look the code of all lord ability in "source", where should i look? can i try to add more lord ability too?

-
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 » 27 Dec 2013, 06:18
It is available, the wording needs to be changed to "lord creatures your opponents control have can't attack"
The available targets for lord ability is viewable from https://code.google.com/p/magarena/sour ... ctory.java
See the factory.put stuff at the top as well as the build method at line 174, https://code.google.com/p/magarena/sour ... y.java#174
The available targets for lord ability is viewable from https://code.google.com/p/magarena/sour ... ctory.java
See the factory.put stuff at the top as well as the build method at line 174, https://code.google.com/p/magarena/sour ... y.java#174
-
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 ShawnieBoy » 27 Dec 2013, 13:17
Here's the remaining code - using Remembrance:
- Code: Select all
[
new MagicWhenOtherDiesTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
return (otherPermanent.isNonToken() &&
otherPermanent.hasType(MagicType.Creature) &&
otherPermanent.isFriend(permanent)) ?
new MagicEvent(
permanent,
new MagicMayChoice(),
this,
"PN may\$ search your library for a card named RN, reveal it, and put it in your hand."
) :
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()) {
game.addEvent(new MagicSearchIntoHandEvent(
event,
new MagicTargetChoice(
new MagicCardFilterImpl() {
public boolean accept(final MagicGame game2,final MagicPlayer player,final MagicCard target) {
return target.getName().equals(event.getRefCard().getName());
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Library;
}
},
"a card named RN"
)
));
}
}
}
]
-
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 melvin » 28 Dec 2013, 02:02
The crash is due to getRefCard failing to find the referenced card in the event. It needs to be pass in after the choice, before the MagicEventAction "this"
In this case, the object referenced should be the otherPermanent and getRefPermanent() used instead. Also note that RN, PN, and SN can only be used for description of an event but not for a choice.
The corrected script is as follows:
In this case, the object referenced should be the otherPermanent and getRefPermanent() used instead. Also note that RN, PN, and SN can only be used for description of an event but not for a choice.
The corrected script is as follows:
- Code: Select all
[
new MagicWhenOtherDiesTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
return (otherPermanent.isNonToken() &&
otherPermanent.hasType(MagicType.Creature) &&
otherPermanent.isFriend(permanent)) ?
new MagicEvent(
permanent,
new MagicMayChoice(),
otherPermanent,
this,
"PN may\$ search your library for a card named RN, reveal it, put it in your hand, and shuffle your library."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()) {
final String name = event.getRefPermanent().getName();
game.addEvent(new MagicSearchIntoHandEvent(
event,
new MagicTargetChoice(
new MagicCardFilterImpl() {
public boolean accept(final MagicGame game2,final MagicPlayer player,final MagicCard target) {
return target.getName().equals(name);
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Library;
}
},
"a card named ${name} from your library"
)
));
}
}
}
]
-
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 ShawnieBoy » 28 Dec 2013, 12:19
I see now - that's excellent, thanks for that
-
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 » 30 Dec 2013, 06:14
i'm trying to figure out the best timing to use fog ability as in this card
"defend" or "block" would be a nice value to use.
- Code: Select all
Dawnstrider.groovy
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Removal),
"Destroy"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [
new MagicTapEvent(source), new MagicPayManaCostEvent(source, "{G}"), new MagicDiscardEvent(source, 1)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
this,
"Prevent all combat damage that would be dealt this turn."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicAddTurnTriggerAction(
MagicIfDamageWouldBeDealtTrigger.PreventCombatDamage
));
}
}
]
"defend" or "block" would be a nice value to use.
-
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 » 30 Dec 2013, 09:57
There is a MagicTiming.Block For the full list, refer to https://code.google.com/p/magarena/sour ... iming.java
-
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 » 31 Dec 2013, 01:30
OK, here is the updated version:
Dawnstrider.groovy
Dawnstrider.groovy
- Code: Select all
[
new MagicPermanentActivation(
new MagicActivationHints(MagicTiming.Block),
"Prevent"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [
new MagicTapEvent(source), new MagicPayManaCostEvent(source, "{G}"), new MagicDiscardEvent(source, 1)
];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
this,
"Prevent all combat damage that would be dealt this turn."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicAddTurnTriggerAction(
MagicIfDamageWouldBeDealtTrigger.PreventCombatDamage
));
}
}
]
-
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 2 guests