need help implementing card
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
need help implementing card
by Willzer » 05 Jun 2014, 15:01
hello guys, i'm new in this program, sorry if this is not the place to ask but I'd like to add the card ''Luminarch Ascension'', I'm still preety confused about the groovy code, could someone help me?
Re: need help implementing card
by ShawnieBoy » 05 Jun 2014, 16:03
Welcome to Magarena!
Groovy code can be a bit daunting at first, but will soon make more sense (Some background in programming always helps though). Looking at other similar card's groovy should always be a best place to start.
With Luminarch Ascension, the main problem is trying to determine if you've lost life or not. At the moment, I don't think this is properly possible. It's not a simple comparison of life from the beginning of the turn to the end, as if you lost life during that turn then gained some back, it still shouldn't trigger.
Getting a copy of the repository so you can look through all the possible methods is good if you know your way around code (https://code.google.com/p/magarena/wiki/DeveloperInfo) Otherwise looking at existing cards and seeing how they work should give some ideas.
I don't mind doing a mini-tutorial, but there's something to be said for discovering and learning things yourself too
You can certainly put together a Luminarch-type card that doesn't have the life change requirement, ie:
Sphinx Sovereign - End of turn trigger
Ebony Owl Netsuke - Each Opponent's
Bloodhall Ooze - You may put a counter on this
Greenhilt Trainee - Activated ability with a condition
Zektar Shrine Expedition - Quest counters and putting a token onto the battlefield
Hopefully that will give you some ideas, if not, let me know and I can go through things in more detail
Good Luck!
Groovy code can be a bit daunting at first, but will soon make more sense (Some background in programming always helps though). Looking at other similar card's groovy should always be a best place to start.
With Luminarch Ascension, the main problem is trying to determine if you've lost life or not. At the moment, I don't think this is properly possible. It's not a simple comparison of life from the beginning of the turn to the end, as if you lost life during that turn then gained some back, it still shouldn't trigger.
Getting a copy of the repository so you can look through all the possible methods is good if you know your way around code (https://code.google.com/p/magarena/wiki/DeveloperInfo) Otherwise looking at existing cards and seeing how they work should give some ideas.
I don't mind doing a mini-tutorial, but there's something to be said for discovering and learning things yourself too
You can certainly put together a Luminarch-type card that doesn't have the life change requirement, ie:
Here's some cards you should look at the groovy code for, and the reasons why:At the beginning of each opponent's end step, you may put a quest counter on Willzer's Ascension.
: Put a 4/4 white Angel creature token with flying onto the battlefield. Activate this ability only if Willzer's Ascension has four or more quest counters on it.
Sphinx Sovereign - End of turn trigger
Ebony Owl Netsuke - Each Opponent's
Bloodhall Ooze - You may put a counter on this
Greenhilt Trainee - Activated ability with a condition
Zektar Shrine Expedition - Quest counters and putting a token onto the battlefield
Hopefully that will give you some ideas, if not, let me know and I can go through things in more detail
Good Luck!
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: need help implementing card
by Willzer » 05 Jun 2014, 16:12
thank you for this explanation, I'll try to make my own ascension as you said following the examples...
Re: need help implementing card
by Lodici » 05 Jun 2014, 17:26
Sounds like a pretty tough card to start with!Willzer wrote:hello guys, i'm new in this program, sorry if this is not the place to ask but I'd like to add the card ''Luminarch Ascension'', I'm still preety confused about the groovy code, could someone help me?
I think this an excellent idea. Groovy makes the scripting capabilities of Magarena very powerful and flexible but it is not exactly the most accessible of languages for someone just interested in implementing a card - I have no idea what @shawnieboy and @melvin are talking about most of the time and even when I look at the groovy stuff it seems a bit obscure.ShawnieBoy wrote:I don't mind doing a mini-tutorial, but there's something to be said for discovering and learning things yourself too
How about creating a new sticky topic in this here forum which starting from the simplest groovy card, introduces a new mechanic, provides a sample card and then uses the "spoiler" feature to...
- | Open
- reveal the groovy answer for that card!
Re: need help implementing card
by ShawnieBoy » 05 Jun 2014, 17:44
I'm all for doing that - with more of the cards being purely scriptable, the barrier of entry for groovy continues to climb. Sometime in the future, hopefully all the cards will be just scripts, and it's only a small step from groovy code to implementing code to the engine itself.Lodici wrote:I think this an excellent idea. Groovy makes the scripting capabilities of Magarena very powerful and flexible but it is not exactly the most accessible of languages for someone just interested in implementing a card - I have no idea what @shawnieboy and @melvin are talking about most of the time and even when I look at the groovy stuff it seems a bit obscure.
How about creating a new sticky topic in this here forum which starting from the simplest groovy card, introduces a new mechanic, provides a sample card and then uses the "spoiler" feature to...
- | Open
- reveal the groovy answer for that card!
I'm far from being a groovy master (That'll be Melvin), but giving people a knowledge of the basics will definitely help.
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: need help implementing card
by ShawnieBoy » 10 Jun 2014, 13:18
First of all I apologize for the reference I gave for putting a token onto the battlefield, the reference I gave was for putting a token onto the battlefield with a play modification (like, "Sacrifice it at the end of turn").
Acorn Catapult would be a more helpful card to look at. It's acually a handy reference, it has:
Hopefully Willzer hasn't been put off, here's my take on Willzer's Ascension:
When I have a bit of time, I'll add some tutorials to the Wiki - it has a basic touch on groovy, but would be an easier reference than searching through a forum thread
Acorn Catapult would be a more helpful card to look at. It's acually a handy reference, it has:
- an activated ability involving tap and a mana cost,
it deals damage to players or creatures - so you can see how to trim it down to effect only one,
it also puts a token onto the battlefield - under someone elses control (potentially) so covers both targeting and ownership of tokens as well as...
getting the token description for them.
Hopefully Willzer hasn't been put off, here's my take on Willzer's Ascension:
- | Open
- Code: Select all
def QUEST_4_OR_GREATER_CONDITION = new MagicCondition() {
public boolean accept(final MagicSource source) {
final MagicPermanent permanent = (MagicPermanent)source;
return permanent.getCounters(MagicCounterType.Quest) >= 4;
}
};
[
new MagicAtEndOfTurnTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game, final MagicPermanent permanent, final MagicPlayer eotPlayer) {
return permanent.isOpponent(eotPlayer) ?
new MagicEvent(
permanent,
new MagicSimpleMayChoice(
MagicSimpleMayChoice.ADD_POS_COUNTER,
1,
MagicSimpleMayChoice.DEFAULT_YES
),
this,
"PN may\$ put a quest counter on SN."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()){
game.doAction(new MagicChangeCountersAction(event.getPermanent(), MagicCounterType.Quest,1,true));
}
}
},
new MagicPermanentActivation(
[
QUEST_4_OR_GREATER_CONDITION
],
new MagicActivationHints(MagicTiming.Token),
"Token"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [new MagicPayManaCostEvent(source, "{1}{W}")];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
this,
"PN puts a 4/4 white Angel creature token with flying onto the battlefield."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicPlayTokenAction(
event.getPlayer(),
TokenCardDefinitions.get("4/4 white Angel creature token with flying")
));
}
}
]
- | Open
- Code: Select all
def QUEST_4_OR_GREATER_CONDITION = new MagicCondition() {
public boolean accept(final MagicSource source) {
final MagicPermanent permanent = (MagicPermanent)source;
return permanent.getCounters(MagicCounterType.Quest) >= 4;
}
};
[
new MagicAtEndOfTurnTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game, final MagicPermanent permanent, final MagicPlayer eotPlayer) {
return permanent.isOpponent(eotPlayer) && !permanent.getController().hasState(MagicPlayerState.HasLostLife) ?
new MagicEvent(
permanent,
new MagicSimpleMayChoice(
MagicSimpleMayChoice.ADD_POS_COUNTER,
1,
MagicSimpleMayChoice.DEFAULT_YES
),
this,
"PN may\$ put a quest counter on SN."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()){
game.doAction(new MagicChangeCountersAction(event.getPermanent(), MagicCounterType.Quest,1,true));
}
}
},
new MagicPermanentActivation(
[
QUEST_4_OR_GREATER_CONDITION
],
new MagicActivationHints(MagicTiming.Token),
"Token"
) {
@Override
public Iterable<MagicEvent> getCostEvent(final MagicPermanent source) {
return [new MagicPayManaCostEvent(source, "{1}{W}")];
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
this,
"PN puts a 4/4 white Angel creature token with flying onto the battlefield."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicPlayTokenAction(
event.getPlayer(),
TokenCardDefinitions.get("4/4 white Angel creature token with flying")
));
}
}
]
When I have a bit of time, I'll add some tutorials to the Wiki - it has a basic touch on groovy, but would be an easier reference than searching through a forum thread
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 19 guests