Friday, June 22, 2007

Design: Magic Engine

The design for the next version of MTG Forge uses a concept that I call “Magic Engine.” A Magic Engine tightly implements all the functionality of a Magic game, like returning a creature from play to hand or drawing a card. Previously every card would handle these actions individually. If a card was bounced to your hand, the card would have to check if it was a token, now there will be a method in the Magic Engine called movePlayToHand(Card) that does all of the checks.

The idea is that if I want to program some really new card that the old engine cannot handle, I can just program a new engine with the new functionality. I should be able to construct cards separately from the engine, so that different engines could use the previous existing cards. CardFactory, the class that actually makes cards, basically just adds SpellAbilities to the cards. For more info on CardFactory and SpellAbility see the column Design: Card

2 comments:

Anonymous said...

Your concept for the Magic Engine sounds interesting. Are you planning on handling cards like the Magic Project does (as an XML file)? I suppose if you did then any card in their xml file would be usable by MTG Forge.

Forge said...

I thought about trying to use Magic Project's XML cards but it is too hard for me. I don't understand their XML format. I'm working on the next version of MTG Forge that has cards hard-coded like the current version.