Page 1 of 141

Card Development Questions

PostPosted: 22 Dec 2010, 06:15
by SoulStorm
I've noticed a number of people besides myself asking card development questions recently, so I thought it might be nice to have a place where all such questions can be dumped.

I'll start...

I've read through a good portion of the API at this point and something occured to me. Every card (that I can think of) can be defined in terms of costs and benefits.

By using iff (if and only if) for cost and then for benefits one can create any card.

Some examples might be helpful...

Kilnmouth Dragon

If Kilnmouth Dragon enters battlefield, if Kilnmouth Dragon on battlefield, if hand reveal x type Dragon cards; then Kilnmouth Dragon gains 3x +1/+1 counters.

If Kilnmouth Dragon on battlefield; then Kilnmouth Dragon gains flying.

If Kilnmouth Dragon on battlefield, if tap Kilnmouth Dragon, if Kilnmouth Dragon x +1/+1 counters, then deal x damage target creature or player.

Sanguine Bond

If Sanguine Bond on battlefield, if controller Sanguine Bond gains x life; then target opponent loses x life.

I'm not a programmer, but this seems like a very simple and organized way to do things.

X variables become easy to use because they are applied separately for each set of if/then statements.

Each if cost is checked before then benefits apply. Each set of statements can have any number of if or then statements.

Each if/then statement is a puzzle piece that increases the complexity and number of cards that can be created.

Is there a flaw in my logic that I'm missing? Do things already basically work this way and I just haven't been exposed to the coding structure long enough to see the big picture?

Re: Card Development Questions

PostPosted: 22 Dec 2010, 14:59
by friarsol
We actually have a structure in place called the Whenever Keyword that handles conditionals like this. (That we're attempting to phase out, in favor of triggered abilities in the AbilityFactory once they are done)

Although it's only for triggered abilities, not for static or activated ones, like Flying or Kilnmouth's damage ability. Those are handled separately by either normal Keywords or the AbilityFactory.

Each trigger sits in a list. When that trigger happens (something enters the battlefield, someone gains life) any "Active" trigger will hit the stack.

For activated abilities, it works differently because of how Maigc works. These requirements are checked at different stages of Ability_Cost, Target, and SpellAbility_Restriction classes. But there is a clear difference between "when I gain life" and "when I activate this card." So these requirements run through their list of things necessary and then say "if all these things are true, then I can activate this ability. This lives in the Ability_Activated.canPlay() function. canPlay() makes sure that not only is it the right timing to activate the ability, but the right zone, and the appropriate costs can be paid, along with any other restrictions. (The last few are actually calling other classes to handle that work, but you get the idea)

Kilnmouth Dragon's damage ability would look something like this:
Code: Select all
A:AB$DealDamage | Cost$ T | Tgt$ CP | NumDmg$ X | SpellDescription$ CARDNAME deals damage equal to the amount of +1/+1 counters on it.
SVar:X:Count$CardCounters.P1P1
Cost is Tapping. All of the rest is information about the ability's effect. Compare this to Hammer of Bogarden's return ability, which sets things like: ActivatingZone, ActivatingPhase, who's Turn it needs to be.

Code: Select all
A:AB$ChangeZone | Cost$ 2 R R R | Origin$ Graveyard | Destination$ Hand | ActivatingZone$ Graveyard | ActivatingPhases$ Upkeep | PlayerTurn$ True | SpellDescription$ Return Hammer of Bogardan from your graveyard to your hand. Activate this ability only during your upkeep.
If someone coded up Amplify (which is pretty similar to Devour) Kilnmouth Dragon could easily be added in.

Re: Card Development Questions

PostPosted: 22 Dec 2010, 17:48
by Rob Cashwalker
If this were a regular Magic game with 2 humans, then the code to interpret the effects would be simple enough to use simpler syntax.

It's providing for the AI, which necessitates signficant extra code for the "Should I Use This Effect" portion of each mechanic. This is where the individual API's in AbilityFactory come in to help. The AbilityFactory_{APIName} class handles both the AI decisions and the actual functionality of the API.

There is one nearly standard parameter all AbilityFactory API's use, Cost$ nearly universal and Target$ parameter is also used by many of them. However each API also has parameters that are specific to them, like NumDamage$ for the DealDamage API. The general ones are parsed in AbilityFacotory, and the specific ones are parsed in AbilityFactory_{APIName}.

Re: Card Development Questions

PostPosted: 22 Dec 2010, 18:38
by Jaedayr
I have been looking for new cards to try to add for a couple days without much luck. Then I searched for Auras and have made my first attempt. I know that it is missing setinfo and picture info but I thought I read somewhere that you have a script that can add that, assuming that the other info is correct. I do not have SVN update ability yet and don't want it until I understand better how to use it for stuff I want to update without updating everything I have.

I have tested this in a game and it seems to function. Could someone tell me where to go from here? If you want to update it yourself that is fine, I am happy for now trying to code the card txt files.

Code: Select all
Name:Cage of Hands
ManaCost:2 W
Types:Enchantment Aura
Text:Enchanted creature can't attack or block.
K:Enchant creature
K:enPumpCurse:HIDDEN CARDNAME can't attack or block.
A:AB$ChangeZone | Cost$ 1 W | Origin$ Battlefield | Destination$ Hand | SpellDescription$ Return

CARDNAME to its owner's hand.
SVar:Rarity:Common
End

Re: Card Development Questions

PostPosted: 22 Dec 2010, 18:56
by friarsol
I was just looking through the missing Urza's Legacy cards and found a few that I'm pretty sure can be done. For all of you who are new to the card file creation try your luck on these:

Code: Select all
Frantic Search
Hope and Glory
Phyrexian Broodlings
Phyrexian Debaser
Phyrexian Defiler
Phyrexian Denouncer
Repopulate
Sick and Tired
The easiest ones to do are the Phyrexians. But I think everything has at least something that can be compared to. If you can't figure it out that's fine, but real world examples will be an easy way to learn.

Re: Card Development Questions

PostPosted: 22 Dec 2010, 19:01
by Jaedayr
Another attempt

Code: Select all
Name:Capashen Standard
ManaCost:W
Types:Enchantment Aura
Text:Enchanted creature gets +1/+1
K:Enchant creature
K:enPump:+1/+1
A:AB$Draw | Cost$ 2 Sac<1/CARDNAME> | NumCards$ 1 | SpellDescription$ Draw a card.
SVar:Rarity:Common
End

Re: Card Development Questions

PostPosted: 22 Dec 2010, 19:18
by Jaedayr
One more.

Code: Select all
Name:Conviction
ManaCost:1 W
Types:Enchantment Aura
Text:Enchanted creature gets +1/+3
K:Enchant creature
K:enPump:+1/+3
A:AB$ChangeZone | Cost$ W | Origin$ Battlefield | Destination$ Hand | SpellDescription$ Return CARDNAME

to its owner's hand.
SVar:Rarity:Common
End

Re: Card Development Questions

PostPosted: 23 Dec 2010, 01:22
by Jaedayr
What do I do next with the three cards that I posted above? I think i need to somehow get the set and picture info but am not sure how to do that. Also I think that I want to know how to update the SVN with only certain changes/additions without doing anything unintended. I have Eclipse/Subversion installed and have been updating my copy almost daily. I also think that I need to PM someone for write access? Any advice/help is welcome, I want to contribute, just not sure what to do next.

Re: Card Development Questions

PostPosted: 23 Dec 2010, 02:45
by Chris H.
Jaedayr wrote:What do I do next with the three cards that I posted above? I think i need to somehow get the set and picture info but am not sure how to do that. Also I think that I want to know how to update the SVN with only certain changes/additions without doing anything unintended. I have Eclipse/Subversion installed and have been updating my copy almost daily. I also think that I need to PM someone for write access? Any advice/help is welcome, I want to contribute, just not sure what to do next.
`
I tend to be super cautious, it is not a bad habit. :) When I create a new card file or modify an existing card file I will launch forge with the card file inside of the cardsfolder. If I made a critical mistake, and it happens at times, forge will give me an error excetion.

This forces me to make sure that the card files that I merge into the SVN will not cause too many problems for other people. They are my friends after all. :)

Most of the standard pic urls use this form:

Code: Select all
SVar:Picture:http://www.wizards.com/global/images/magic/general/
`
At the end of this will be the actual file name for the jpg picture. Take a look at a few of the existing card files to see what I mean. The Portal pics are not available on the wotc web site for some reason and we have had to use the pic url for some other web site.

We have a topic for people who need help in getting the software needed for SVN access here How to get started? . This topic would be a good place to ask and answer your questions concerning how to get yourself ready to make commits to the SVN.

Re: Card Development Questions

PostPosted: 23 Dec 2010, 13:31
by SoulStorm
New Card: Shackles

Name:Shackles
ManaCost:2 W
Types:Enchantment Aura
Text:Enchanted creature doesn't untap during its controller's untap step.
K:Enchant creature
K:enPumpCurse:HIDDEN CARDNAME doesn't untap during your untap step.
A:AB$ChangeZone | Cost$ W | Origin$ Battlefield | Destination$ Hand | SpellDescription$ Return CARDNAME to its owner's hand.
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/shackles.jpg
SetInfo:INV|Common|http://magiccards.info/scans/en/in/37.jpg
End

The card has been tested for both AI and player use. I added it to combo with Sigil of the Empty Throne. Some AI to allow the card to be effectively used by the AI would be appreciated at some point.

Also, I noticed that the AI would play more than one copy of the card on the same creature. This would work fine with some enchantments, but is redundant with this one. Is there a NoStack variable that I'm not aware of?

I'd add it to the SVN myself (or I'd at least try :mrgreen: ), but I still have the "Could not find the main class:forge.Gui_NewGame. Program will exit" problem. So anyone else who would like to add it, please do.

Edit

Here's another, also fully tested.

Name:Shimmering Wings
ManaCost:U
Types:Enchantment Aura
Text:Enchanted creature has flying.
K:Enchant creature
K:enPump:Flying
A:AB$ChangeZone | Cost$ U | Origin$ Battlefield | Destination$ Hand | SpellDescription$ Return CARDNAME to its owner's hand.
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/shimmering_wings.jpg
SetInfo:10E|Common|http://magiccards.info/scans/en/10e/107.jpg
End

Re: Card Development Questions

PostPosted: 23 Dec 2010, 14:54
by Rob Cashwalker
SoulStorm -

Try running Gui_NewGame from inside Eclipse instead of trying to build and run the jar.

Re: Card Development Questions

PostPosted: 23 Dec 2010, 16:21
by Chris H.
I added Conviction, Capashen Standard, Shackles, Shimmering Wings to the SVN. Thank you Jaedayr and SoulStorm.

Re: Card Development Questions

PostPosted: 23 Dec 2010, 18:32
by SoulStorm
Chris, thanks for adding the cards!

Rob and Sol, thanks for the helpful answers to my question in the first post.

Rob your suggestion worked perfectly. Now my question is, what are the advantages and disadvantages to running Gui_NewGame from inside eclipse vs. the instructions Chris gave me. In case you didn't see the before:

"While in Eclipse, you should select Window -> Show View -> Project Explorer. With the Project Explorer view active you can navigate the folders and find the individual contents of the ForgeSVN project.

While in Eclipse, you should then select Project -> Build Project or Build All. You can click on and highlight the ForgeSVN project folder. Right click and there should be a Run As -> Java Application choice. This will give you a list of java classes, choose the one named "Gui_NewGame - Forge". The forge New Game window should appear after a few seconds. Give it time.

At this point you can select File -> Export... -> Java -> Runable JAR file. Select the Launch configuration and Extract required libraries into generated JAR options. Use Browse to choose the Export destination. Click on finish. There may then appear several warnings which are not very important. You will then get the JAR file to launch the game. You can copy the necessary files from the forge project, the new JAR file, your previous pics folder, decks folder and questData file over (place the files into a separate folder and not into the forgeSVN project folder) and you should be up to date at that point."

Im assuming I can copy my pics folder and such into the ForgeSVN Workspace?

I've made another card. I'm going to review the instructions to upload to the SVN. You'll either see it there or see another question here. :mrgreen:

Thanks!

Re: Card Development Questions

PostPosted: 23 Dec 2010, 19:23
by Chris H.
Jaedayr wrote:What do I do next with the three cards that I posted above? I think i need to somehow get the set and picture info but am not sure how to do that.
`
Sol created a Python script which will add in the set data. It is probably best to let the Python script handle the set data. The standard pic url is fairly easy to put together. As far as the rarity goes, we tend to use the most common one if there are sets using different rarity values for a given card.

Python is another dev system and language. It is included as part of the standard Apple Mac OS system install. I have it on my iMac computer. I only have modem dial up access to the internet and it is not fast enough to run the script.

Other OS' may not include Python as part of the standard install. The Python dev system can be downloaded and installed but you may find that you would rather not deal with another dev system. Taking it one step at a time can make it easier to ramp up. :D

Re: Card Development Questions

PostPosted: 23 Dec 2010, 19:27
by Chris H.
Jaedayr wrote:What I also think that I need to PM someone for write access?
`
Send a PM to Dennis with your google email address and he can give you commit status.