Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

878609 Posts in 32929 Topics- by 24337 Members - Latest Member: kellerx25

May 22, 2013, 09:33:21 AM
TIGSource ForumsDeveloperCreativeDesignWriting a virtual trading card game
Pages: [1]
Print
Author Topic: Writing a virtual trading card game  (Read 935 times)
Zachary Lewis
Level 1
*


Professional by day, indie by night.


View Profile WWW
« on: March 15, 2010, 03:17:32 PM »

I am planning to start development on a video game based on a trading card game (think Pokèmon Trading Card Game or Duels of the Planeswalkers). The decks will be fixed, and I am not concerned about writing AI at the moment; however, what I am concerned with, is the logic.

Since I don't want to write a class for every card, I'd like to pull in information from a database regarding the cards statistics and abilities. This breaks down when you begin to think how each card can have non-ability rules text (in Magic, think of Flying as an ability and "Whenever this creature deals damage to more than one blocking creature, the blocking creatures' controller gains one life" as a non-ability).

I have determined that each ability will usually only occur at specific times, leading me to an event-driven solution. Typical events are things like: Entering play, leaving play, dealing damage, taking damage, attacking, blocking, becoming the target of a spell or ability, et cetera. On these events, I want to check for the cards' abilities and perform whatever actions are required.

Taking the above ability into consideration ("Whenever this creature deals damage to more than one blocking creature, the blocking creatures' controller gains one life"), it would occur during the "deal damage" event. It would need to know if it was blocked, if it dealt damage to the blocking creature, and if it dealt damage to another blocking creature. If so, its controller would have a "gain life" event with a value of one (other shit could happen during this event, too).

Does anyone have any experience with something like this? I really don't want to write a scripting language for these cards, nor do I want to write complex scripts for every single card. I was thinking of using an aspect-oriented approach, but I'm not sure where to being looking for information on implementing it in a situation like this. As always, any help or suggestions would be appreciated. Tiger
Logged

Richard Kain
Level 10
*****



View Profile WWW Email
« Reply #1 on: March 16, 2010, 02:09:48 PM »

I'm actually planning something similar. However, I am intentionally keeping the logic for my game as simple as possible. I'm not going to be going the full-on CCG route, like Yu-Gi-Oh or Magic: The Gathering. My effort is going to be basic turn-based, with some very simple rules.

I would advise that you also try to keep it simple. You should first break down the logic of your game down into the most abstract categories possible. You will want to first define what each player can or can't do on their "turn," and how the end of their turn will be reached. I am not that familiar with traditional CCGs, so I can't help you too much in that area. I would imagine that some options can limit your oponent's turn, so the length of each turn would probably have to be variable.

From your description, it seems like you would be interested in a more "component" approach to the design of your logic structure. It might be a good idea to check out the PushButton Engine. This is a Flash AS3 engine that uses a component architecture. Even if you don't want to use the engine itself, you can peruse the source code for an idea on how component-based games are programmed. In component architecture, objects are as generalized as possible, and then have various components added to them. You could make an extremely generalized "card" class, and then attach various components to each individual card to modify its properties. This type of architecture also lends itself well to scripting with XML or databases, so you would be able to define your available card types there, instead of in the source code.
Logged
Zachary Lewis
Level 1
*


Professional by day, indie by night.


View Profile WWW
« Reply #2 on: March 16, 2010, 02:22:31 PM »

Unfortunately, a company has approached me with their product, so I can't change the rules. Sad

I have been looking into a component-based approach, and it seems very well suited for the game.

I want to stay away from writing complete code for every class (I'll be working in C#), but I may implement some simple scripting for more complex cards.

Thanks for your input! I'll be sharing my experience and thought here as I progress, so maybe we can help each other out!
Logged

LiquidAsh
Level 2
**



View Profile WWW
« Reply #3 on: March 19, 2010, 09:42:36 PM »

Sounds like an event driven system with some minimal action/response scripting would word well.  Then you just allow each card to react to any events that they care about reacting to.  Depending on the complexity of these reactions, you can often get away with a simple action-modifiers-object set for each response.  You might also consider having different sets of events and responses for different groups of cards (instants versus interrupts as an example from magic).  I guess it's hard to be very specific without more details about the game.  In a sense, it's nice that you have a finite set of cards to implement.
Logged

If you found this post useful, you might enjoy Rollaway.
SirNiko
Level 10
*****


View Profile Email
« Reply #4 on: March 21, 2010, 06:15:42 PM »

I would suggest moving this topic to the "Technical" section. You'll probably get much better responses there.

-SirNiko
Logged
Zachary Lewis
Level 1
*


Professional by day, indie by night.


View Profile WWW
« Reply #5 on: March 21, 2010, 07:15:09 PM »

Would an admin move this topic, please? Tiger
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic