Wednesday, June 10, 2009

What is a Card?

MTG Forge has a card object which represents a real-world, cardboard card. This sound simple but it gets a little bit complicated. Let's say that I want to destroy one of your Forest's but you want to bounce it, so you have to know which specific Forest card that I am targeting. In the real world you can just point to the specific Forest, while a computerized game of Magic has to show the user. Magic Online uses nicely drawn arrows while MTG Forge just tells you the targeting card name and its unique number.

At the beginning of the game MTG Forge gives each card a unique number much like the old Shandalar game. Whenever a card is copied, the card's unique number is copied also. In MTG Forge every time a card's attributes need to be reset, like when a creature is going to the graveyard, a new copy of the card is made that has the same unique number. In MTG Forge, every time a card changes zone a new copy is made. I think that making a new copy of a card is easier than saving all of the base attributes and then resetting them, Card.reset().

The card name is important but so is the unique number. Ideally the unique number would not be shown to the user and little arrows would be drawn to show targets.

Nothing I write about it really rocket science just one guys opinion about programming Magic. Just finding the subject is the hard part, the rest is usually straightforward.


nantuko84 said...

have you already seen new mtg rules?
what do you think about changes in damage stack? I guess it will take some time to get used to it

Nurova said...

Here's the link to those rules in case you haven't seen 'em.

Also, for Forge 2.0 are you going to keep the idea of making a new card when it changes zones? If so, I can see why making the stack a zone would cause a lot of problems.

Rob Cashwalker said...

Re: New Rules


We were prepared for the terminology changes, which are simple, and make sense. We were prepared for the mana pool and mana burn changes... which didn't affect MTGForge yet, but are tolerable.

But the sweeping changes to combat and damage-based abilities!?!?
Now, more than ever, MTGForge needs a stop between attackers and blockers, cause the only stop we have, doesn't exist anymore!

And my pet deck in cardboard is based on exalted w/ multiple lifelink. (Rhox War Monk + Loxodon Warhammer + Battlegrace Angel)

Anonymous said...

Here is something to chew on.. a card in mtg is only used in the following zones: hand, library, graveyard, and any kind of removed from the game zone.

A card is never on the stack; Spells are.

A card is never in play; Creatures, equipment, enchantments, artifacts, etc.. are.

We just use cards to represent these things in the real world magic since it wouldn't make much sense to carry around 3 versions of everything for the different zones, but in software I think the card object should cast a spell when it goes on the stack and a spell should cast a new object when it resolves.

Anonymous said...

Actually the spell card goes on the stack:

When a spell is played, the physical card is put on the stack. When an ability is played, it goes on top of the stack without any card associated with it (See Rule 409.1a). CompRules 2007/10/01

A card is never in play;

This is more of a naming convention as cards in play are named permanents.

200.6 - A permanent is a card or token that's in play. (See Rule 214, "Permanents.") CompRules 2003/07/01

If you wanted to stay true to the rules you should move the card from one zone to the other in a proper order.

Forge said...

Also, for Forge 2.0 are you going to keep the idea of making a new card when it changes zones?

Yes, this is mostly done to "reset the card." So when a creature is bounced to your hand all of its stats (power/toughness) is reset back to normal.

If so, I can see why making the stack a zone would cause a lot of problems.

The problem with the stack is technically it holds spells and abilities and not cards, also cards may have multiple spells or abilities, Fire/Ice or a creature with two activated abilities.

Currently MTG Forge only allows SpellAbility objects to be put on the stack, but every SpellAbility has a reference to the Card object, Elvish Piper activated ability holds a reference back to the card Elvish Piper, SpellAbility -> Card. In version 2 I'm just going to reverse SpellAbility and Card, and put the Card on the stack that points to the SpellAbility that is being played, Card -> SpellAbility. You the player won't notice but I think it will make a few things much easier.