When you program, you should always try to program at the highest level. "This level provides the abstractive power to work with a problem on its own terms. Your code at this level should be somewhat readable by someone who's not a computer-science whiz. At this level your code depends more on the tools you've built than on the capabilities of the language you're using." [1]
Basically your goal is layer computer-science data structures until you can use language similar to the problem domain. If your problem domain is Magic: The Gathering hopefully you have methods like startGame() and drawCard(player). These methods are "high level" because they can be understood by a Magic player who isn't a computer programmer.
Thankfully MTG Forge has a number of high level methods and objects. In the beginning I didn't have drawCard() and I would just duplicate the code. Needless to say this isn't the best solution, so I created drawCard() out of convenience.
Not all methods and object can be defined by the Magic glossary. Paying the mana cost involves a number of "artificial steps" that the computer has to do which are trivial in a real world game such as checking to see if the mana is necessary as well as untapping lands when the user cancels and doesn't pay for the spell. Combat also involves many artificial steps that the computer needs in order to make combat work correctly such as assigning damage and triggering combat abilities like Hypnotic Specter.
In closing, write high level code because it will save you time and frustration in the long run.
p.s.
[1] - Code Complete by Steve McConnell. This is a great programming book that is one of my major influences. This book is better than all of the books that I had to read for my computer degree, bachelor's in information science. I suggest that you try to find it at your local library.
The book has both a first and second edition. I still have the first edition but the second edition has probably 10% new and updated material. If you are cheap buy a used copy of the first edition.
Wednesday, May 13, 2009
Subscribe to:
Post Comments (Atom)
3 comments:
Really love this program, thanks for making it.
In the lastest update I can't get the draft to save. Also, Troll Ascetic doesn't have shroud, and the picture for Wilt-leaf Cavaliers doesn't download.
There are a few key cards this program needs to complete some archetypes. So here are my requests for future versions: The Rack, Nyxathid, Buried Alive, Entomb, Trinket Mage, Chalice of the Void, Engineered Explosives, Tinker, Morphling, Force of Will, Mana Leak, Vedalken Shackles, Mistbind Clique, Spellstutter Sprite, Cryptic Command, Ponder, Rakdos Pit-dragon, Gathan Raiders, Gifts Ungiven, Goblin Piledriver, Goblin Matron, Seige-gang Commander, Pernicious Deed, Tombstalker, Smother, Life from the Loam, Terravore, Skeak Attack, Berserk, Crome Mox, and fetchlands.
These are some good card suggestions (and some of them are definitely possible), I'll add them to my long list of cards to implement...
MTG Forge is an "ongoing project" which means "it will never get done because there are always more stuff to add."
Post a Comment