Magic - Domain Specific Language
Recently I read an article about domain specific languages (DSL). The goal of DSLs is to allow you to write at the highest level of abstraction (which is your goal anyways since high level code is shorter and more straight to the point that low level mucking). A DSL can be "interal" writting in a programming language like Java, game.drawCard(). Parts of Forge like CardFactory is an internal DSL. A DSL can also be external, written using plain text and then your program has to read (parse) it, "player 1 draw a card".To everybody how doesn't understand what I'm saying, don't worry about it. I try not to be "too technical" but some of this stuff is "all technical". I always say, "The devil is in the (technical) details."
Writing a super high level DSL for Magic sounds very interesting and I don't really have an idea of what it would look it. Obviously some actions happen concurrently (at the same time) so that has to be taken into account.
On my blog I've talked about different ways of encoding a Magic card. If you use plain text to encode a card, that is an external DSL. Obviously everybody is going have different ideas of how to do this but below are some of my thoughts.
Some people won't like my "text" labels but I think they would simplify the programming. On a separate issue, I don't know the pros and cons of putting each card in a separate file.
Shock
R
Instant
Spell
Text: Shock deals 2 damage to target creature or player.
Target: creature or player
Resolve: damage target creature or player, 2
Prodigal Pyromancer
2 R
Creature Human Wizard
1/1
Activated Ability
Text: tap: Prodigal Pyromancer deals 1 damage to target creature or player.
Cost: tap
Resolve: damage target creature or player, 1
Venerable Monk
2 W
Creature Monk
2/2
Triggered Ability
Text: When Venerable Monk enters the battlefield, you gain 2 life.
Trigger: enters the battlefield
Resolve: gain life – controller, 2
Holy Strength
W
Enchant Creature
Static Ability
Text: Enchanted creature gets +1/+2.
Effect: enchanted creature gets, +1/+2