Spells and possibly abilities with the whenever keyword
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
6 posts
• Page 1 of 1
Spells and possibly abilities with the whenever keyword
by Beached As » 17 Jul 2010, 18:44
I didn't plan for this when i was coding the WheneverKeyword but it turns out that with a certain set of parameters, the WheneverKeyword can be used to cast spells (and possibly activate abilities but i haven't tried it out yet). For example, the code for Doom Blade would be:
), the WheneverKeyword could possibly replace all CardFactories and if a similar keyword is made for State Effects like the static bonuses from cards like Akroma's Memorial and Fury Sliver, then we could well on the way to implement most of the cards into forge. It goes without saying that alot of work is required for this to happen
This would be a big change, and my question to you guys is should we implement this? The reason why i ask is implementing the code could potentially lead to many unseen bugs as it would be replacing a current system with a different one. The benefits however, are that the code is relies more on keywords rather than identifying the card name of a spell or ability, making cards easier to code (Once the keyword can recognise the effect) and bugs more obvious.
EDIT: The new code for Doom Blade is now available on the SVN, have a look
- Code: Select all
Doom Blade
1 B
Instant
no text
WheneverKeyword:ActualSpell:Self:Any:Destroy/1:NormalInput/Specific/NonColor.black/Type.Creature:ASAP:No_Condition:No Special Condition:Destroy target nonblack creature.

This would be a big change, and my question to you guys is should we implement this? The reason why i ask is implementing the code could potentially lead to many unseen bugs as it would be replacing a current system with a different one. The benefits however, are that the code is relies more on keywords rather than identifying the card name of a spell or ability, making cards easier to code (Once the keyword can recognise the effect) and bugs more obvious.
EDIT: The new code for Doom Blade is now available on the SVN, have a look
- Beached As
- Programmer
- Posts: 110
- Joined: 23 Feb 2010, 07:48
- Has thanked: 0 time
- Been thanked: 0 time
Re: Spells and possibly abilities with the whenever keyword
by DennisBergkamp » 17 Jul 2010, 19:39
Wow, that is awesome!!!
I think we should definitely use that implementation for as many cards as possible... but why for Doom Blade? spDestroyTgt already keywords it pretty good
The main cards that could would use keywording would be the static effects, those are coded pretty ugly currently, or perhaps start out with non-existing cards, that way we wouldn't introduce new bugs to old cards...
I think we should definitely use that implementation for as many cards as possible... but why for Doom Blade? spDestroyTgt already keywords it pretty good

The main cards that could would use keywording would be the static effects, those are coded pretty ugly currently, or perhaps start out with non-existing cards, that way we wouldn't introduce new bugs to old cards...
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Spells and possibly abilities with the whenever keyword
by Sloth » 17 Jul 2010, 20:20
The whenever keyword was already the most versatile keyword ever, but also using it for spells really blows my mind. It would help a lot with adding new cards, since every user can try adding cards without compiling the game.
I hope you don't mind me already adding cards with your keyword Beached As, but I just couldn't resist. If you want to change something in the structure of the keyword, don't hesitate. I'm willing to work the cards over again, if they need to be adjusted.
Thanks for your great work!
I hope you don't mind me already adding cards with your keyword Beached As, but I just couldn't resist. If you want to change something in the structure of the keyword, don't hesitate. I'm willing to work the cards over again, if they need to be adjusted.
Thanks for your great work!
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Spells and possibly abilities with the whenever keyword
by Rob Cashwalker » 18 Jul 2010, 02:18
I'm a little split here.
On one hand, I think it's great that there's some sort of universal keyword.
On the other, I'm all for keeping things simple.
The spDestroyTgt keyword, is a simple, purpose-built keyword for destroying things. It handles all aspects of the effect, which is more than the function of just destroying something.
For example, I don't see any provision for the AI for such an implementation of Doom Blade. Sure, it will work when cast and maybe the AI will choose good targets when cast, but should the computer play it now?
IF we're going to unify the keyword system, I think it should be done from the ground-up, instead of using this particular keyword and all the functionality it needs for actually handling "Whenever" events.
Two methods we've discussed, such that the keywords should stay basically the same:
We could adapt our existing keyword system into a SpellAbilityFactory. It takes in the keyword string, and gives back a SpellAbility.
We could have a single SpellAbility on each card, which interprets keywords on the card at run-time. For example, you click on a card with a pump keyword, the "Master" SpellAbility reads the keyword, and performs the actions specified.
On one hand, I think it's great that there's some sort of universal keyword.
On the other, I'm all for keeping things simple.
The spDestroyTgt keyword, is a simple, purpose-built keyword for destroying things. It handles all aspects of the effect, which is more than the function of just destroying something.
For example, I don't see any provision for the AI for such an implementation of Doom Blade. Sure, it will work when cast and maybe the AI will choose good targets when cast, but should the computer play it now?
IF we're going to unify the keyword system, I think it should be done from the ground-up, instead of using this particular keyword and all the functionality it needs for actually handling "Whenever" events.
Two methods we've discussed, such that the keywords should stay basically the same:
We could adapt our existing keyword system into a SpellAbilityFactory. It takes in the keyword string, and gives back a SpellAbility.
We could have a single SpellAbility on each card, which interprets keywords on the card at run-time. For example, you click on a card with a pump keyword, the "Master" SpellAbility reads the keyword, and performs the actions specified.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Spells and possibly abilities with the whenever keyword
by Beached As » 18 Jul 2010, 02:57
Hmm, i tend to agree with you here Rob, especially at the point where if would be better to have a keyword BASED on SpellAbilities instead of applying the whenever keyword to it. It was my original idea to have a seperate keyword but i just seemed cool that the WheneverKeyword worked for spells. I do think however, that a overarching keyword for SpellAbilities would be necessary at some point. As for actually implementing the overarching keyword, i'm not sure how to go about it and it gets even more complicated with cards with more than one SpellAbility (e.g. cards with kicker). Both the two options given would work fine i think, but perhaps the first option would have more support for cards with more than one SpellAbility. I'll reverse the change on Doom Blade but i'll leave the foundation for SpellAbilities there.Rob Cashwalker wrote:I'm a little split here.
On one hand, I think it's great that there's some sort of universal keyword.
On the other, I'm all for keeping things simple.
The spDestroyTgt keyword, is a simple, purpose-built keyword for destroying things. It handles all aspects of the effect, which is more than the function of just destroying something.
For example, I don't see any provision for the AI for such an implementation of Doom Blade. Sure, it will work when cast and maybe the AI will choose good targets when cast, but should the computer play it now?
IF we're going to unify the keyword system, I think it should be done from the ground-up, instead of using this particular keyword and all the functionality it needs for actually handling "Whenever" events.
Two methods we've discussed, such that the keywords should stay basically the same:
We could adapt our existing keyword system into a SpellAbilityFactory. It takes in the keyword string, and gives back a SpellAbility.
We could have a single SpellAbility on each card, which interprets keywords on the card at run-time. For example, you click on a card with a pump keyword, the "Master" SpellAbility reads the keyword, and performs the actions specified.
Thanks Sloth, and i should be thanking you as well. Making cards easier to code is why im here and if people are willing to add cards with keywords, it gives me more time to expand keywords (so people can make more cards, so i have more time to expand keywords, so people can make more cards. What a cycle!) Generally if i change the keyword, i will test a few random cards which COULD be affected by the change, so i try to have all the previously working cards in good shape before i upload anything to the SVN, but i do miss things sometimes.Sloth wrote:The whenever keyword was already the most versatile keyword ever, but also using it for spells really blows my mind. It would help a lot with adding new cards, since every user can try adding cards without compiling the game.
I hope you don't mind me already adding cards with your keyword Beached As, but I just couldn't resist. If you want to change something in the structure of the keyword, don't hesitate. I'm willing to work the cards over again, if they need to be adjusted.
Thanks for your great work!
Doom Blade was the first card that came to my head lol. As for StaticEffects, thats my next projectDennisBergkamp wrote:Wow, that is awesome!!!
I think we should definitely use that implementation for as many cards as possible... but why for Doom Blade? spDestroyTgt already keywords it pretty good![]()
The main cards that could would use keywording would be the static effects, those are coded pretty ugly currently, or perhaps start out with non-existing cards, that way we wouldn't introduce new bugs to old cards...

- Beached As
- Programmer
- Posts: 110
- Joined: 23 Feb 2010, 07:48
- Has thanked: 0 time
- Been thanked: 0 time
Re: Spells and possibly abilities with the whenever keyword
by silly freak » 20 Jul 2010, 19:11
i think we should go for clearness, like rob said. what we could do is to implement new keywords by "wrapping" the whenever keyword. like, you use the destruction keyword, which under the surface builds a "whenever" style string and lets the whenever keyword do the work; saves time implementing keywords but also keeps the cards readable
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 54 guests