Monday, March 30, 2009

Millions of Details

When writing a Magic implementation there are a million little details to keep in mind. Let’s say the user interface (UI) shows the mana cost of all the cards, but some cards reduce the amount of mana that you have to pay. Does the UI update all of the cards’ mana costs or does it just show the printed mana cost? For convenience the UI probably loads the card’s jpg, so the mana cost is never reduced and the player has to keep that in mind.

Cards and abilities that have “may” in them are also problematic like Dragon's Claw, which is an artifact that costs 2 and says, Whenever a player plays a red spell, you may gain 1 life. It is much easier to always have a card do something, which is what the player would do 99% of the time, but that other 1% causes much difficulty. When I code the AI for a card like Dragon’s Claw, the AI always gains life.

In a real game of Magic the player has to speak up and put any “may” abilities on the stack. But I believe the rules say that the ability always goes on the stack and the player has a choice when the ability resolves. So should a program like Magic Online put the ability on the stack or require the user to “play” that ability, thus making the user less lazy and more alert.

The main problem when programming Magic is the large volume of rules, which players internalize after awhile. The rules make programming hard, but they make the game fun.

3 comments:

willow said...

At some point you have to ask yourself if you want your game to be closer to a game rather than a simulation.

If you want to be closer to the simulation, then your players have to be alert. It means you respect the rules 100%. If a card says "may", then you popup a window that asks the player if they want to perform the action or not.
Again, if it is a simulation, you'd rather show the "real" card and let the players figure out the
"new" cost for your first example.

You can also have a kind of "enhanced reality" display mode. The game shows the actual printed cards, but if the player presses a certain key, extra information appears (real cost, enchantments that have an effect on the card, etc...)

On the other hand, you can decide that you want to favor the "game" aspect, and take some distance with the simulation aspect.
Having a menu to popup whenever a "may" keyword appears can break the flow of the game, so you could decide that the action always takes place, leaving an opportunity for the user to re-enable the "popup" on the options menu.

rising fruition said...

Actually, the UI should NOT change the mana cost, because the mana cost has not changed. (The amount of mana you need in order to PLAY the spell may have changed, but the mana cost hasn't. Or maybe I mean to say "converted mana cost".)

You may want willow's "enhanced reality" display mode for telling you how much you need to pay to play each spell.

And that is just an example of the millions of details that comprise the game of Magic. There are other subtle details like "playing a land" versus "putting a land into play". The former can only be done once per turn, but the latter can be done as many times as you want.

I have yet to even start coding a Magic game, so I have deep respect for someone who has, no matter how many rules are still left unimplemented, or how many cards there are left to program. Even coding 80% of the game is a challenge. Heck, even 50% is quite an accomplishment.

Forge said...

Willow,

Good point, game or simulation. Much like racing games (that I read about and don't play) some games are simulations and some are arcadey, feel-good go-fast type of games. Mostly I just want MTG Forge to be fun.