Wednesday, September 23, 2009

Software Evolution

When I started programming MTG Forge I didn't program planeswalkers, vigilance, or exalted. I started out with plain, vanilla creatures and then added flying and haste later. MTG Forge "evolved" one step at a time. I didn't know how everything was going to fit together but I wrote good code and didn't worry about the future.

My first big challenged was Glorious Anthem, a staple of white weenie decks. I had no idea how I was going to program it. Anthem is a great card and I wanted my version of Magic to have it. MTG Forge already implemented a simple "check state effects" that moved creatures to the graveyard and I experimented by creating Anthem in that code. It may not be the best way to code it but it worked and I was very happy.

MTG Forge didn't start out supporting flashback but since MTG Forge has a flexible architecture, flashback wasn't too hard to add. MTG Forge easily allows spells and abilities to be played in any zone. Cycling is another ability that works only when the card is in your hand. (Each spell or ability has a canPlay() method which returns true if the spell or ability can be played in the particular zone that it is in.)

Giant Growth and end of turn effects is another good example where I had to experiment a little bit to see what things worked and what didn't. (Giant Growth uses the Command Pattern and executes "at the end of turn" to return the creature to normal.)

The goal of any good computer program is to start with a good architecture (foundation) and then build on it. I think that programming is similar building a house of cards, you have to be extremely careful or everything will fall down and crash the computer. MTG Forge does have its share of bugs and crashes but hopefully they aren't too annoying.

7 comments:

Unknown said...

Since you mentioned flashback I thought I'd mention that firebolt can't be flashed back.

Forge said...

Oops, MTG Forge is a fly by the seat of your pants type of thing.

nantuko84 said...

I'd like to thank you once again for your architecture once again, Forge ;) It's really flexible and the fact that the whole set can be implemented without major changes proves that!)

Unknown said...

MTGForge flies by the seat of its pants... like Han Solo and the Millenium Falcon. It looks like a hunk of junk, but she's got it where it counts, kid!

Forge said...

Nicely said Rob. (I'm a huge Star Wars fan also.)

Anonymous said...

Hey,
First to say, you're (still) doing a great job. I got a question though:

I downloaded your newest version (full) and unpacked it. When I doubleclick run-forge, it doesn't start like it did in earlier versions ('till now it always worked on my pc). The error says: "Could not find the main class. Program will exit."

What went wrong?

Greetz!

Brent Sullivan said...

I left a comment in "new version" recently, but i thought it would be appropriate to add something here also.

when i started looking at making Magic in vb.net, i looked at all my vanilla cards and wrote down the basics of each card;
name:cost:P:T

then i looked at keyword static abilities (independant of any set) like haste, flying, first strike, etc.

then i moved on to creatures with other abilities, trying to translate each ability into a set of logic steps to make it easy to add cards (like your cards.txt format....)

eg.
shambling remains:1BR:4:3:[:2:]:NoBlock [my keyword]:Unearth(BR)
and maybe another value to indicate how many abilities (in this case, 2)

or;
Rhox Bodyguard:3GW:2:3:[:2:]:Exalted :when(enter,me.life(+3))

the last bit is what i am experimenting with to make it easy for ANYONE to add ANY card.

Also, i have had a bit of trouble understanding how your cards.txt file fits in with working out the cards, would you be able to provide a plain text version of retrieving the data for a card in cards.txt??

many thanks for a job well done,
Brent Sullivan