One object to rule them all and in the darkness bind them. OK, enough of my Lord of the Rings paraphrase. In MTG Forge version 2 I have an object named “RulesEngine” that holds all rules of a Magic game. All game actions go through the Rules Engine like drawing a card, destroying a creature or advancing to the next phase.
Let me briefly explain what an object is to non-programmers. An object is a group of code that works on the same data. In Magic terms, a Card object would handle all card operations like changing the toughness, adding keywords and getting the card name. The term “class” is also thrown around and for our purposes “class” means the same as object. In Java object names are typically capitalized so that is why I wrote Card object, instead of card object.
Anyways, back to the Rules Engine. Unfortunately the Rules Engine object will be a very complicated and long, since it has to do everything. Currently MTG Forge tries to group many of the rules into GameAction but I did this mostly to save code. All of the rules should be put in one object. In case some rule needs to be fixed or modified, I know where to go, the Rule Engine object.
The cool thing about the rule engine is that it can be easily modified. Do you want to play type 4 with unlimited mana, done. Any rule can be modified. Complicated cards like Mana Flare (each land produces one extra mana) should be fairly simple to implement using the rules engine. I’m also hoping to be able to program one of Magic’s most powerful cards, Time Walk. (1U, Sorcery, take an extra turn after this one.)
I must complete my Lord of the Rings paraphrase. I find this terribly funny. And in case you didn’t get it, the one object to rule them all is the Rules Engine.
One object to rule them all, One object to find them,
One object to bring them all and in the darkness bind them