Database and Class Model for Customizable Cards for TCG

Started by
2 comments, last by BoReDoM_Inc 14 years, 5 months ago
Hi all, I'm working on the database and class design for an online multiplayer trading card game. It would be somewhat of a simplified version of magic the gathering. I'd like to build the game so that I could easily add new cards to the game (unit or spells) without having to recompile. Preferably through somekind of card creation tool, although I'm open to other methods. Has anyone had any experience with something similar? Does anyone know where I could find db or class diagrams for similar systems? Really, I'd appreciate any help or guidance on this, even if it means changing my approach. Thank you
Advertisement
If the game is meant to be real-time then you probably won't want to use a database to store the cards types, although you certainly could use a lightweight SQL server like SQLite to store cards when the server shuts-down. When it boots up you can then load the cards from a database.

In regards to this I'd recommend having only, at most two classes that represent cards. Each cards could have a bunch of parameters representing, health, attack listing, cost etc. each card type would then be registered in a dictionary container on the server (and client, although the client may not need the whole list). Creating new cards could be done two ways, first you could have an admin account that you login with from a client, then on the client you could display a card creator tool, once the admin has finished creating a card the data can be sent to the server, verified and then added to the list of existing cards.

The alternative would be to update a database or text file where all the cards are stored, you'd still need some mechanism to tell the server to reload the list of cards and as such you'd probably still need an admin account to instruct the server to do so.
Thanks for the response :)

I planned to have something like what you're describing where the cards are loaded on startup and refreshed by the admin when necessary.

The problem I'm facing is in how to design the classes and db tables in such a way where cards can be constructed using a card creator tool. Maybe it would help if I explained what I have so far:

Card - A class to represent a card, this includes the name, description, type (summon or spell), and cost of a card. For monsters, it will also have health, attack, ect...

Ability - A collection of effects that are produced by the card (these are game effects, not graphical). An ability also contains information on valid targets. Some cards such as monsters can have multiple abilities.

Effect - An ability "building block". One or more effects can be added to an ability. Example effects could be "healed for x" or "damaged for x". Effects also hold information on which target to affect (selected target, all monsters, opposing player, ect...), the duration of an effect (x turns, current action, ect...), when the effect occurs (immediately, start phase of target's owner, ect...).


I've done some design on this but I'm unsure of how well it will work and I'd really love to see what others have come up with to handle this.
What you've got so far seems like quite a well structured design. The way I'd go about making the database would to have a table each for Cards, Abilities and Effects. The Effect table would have columns for all the possible statistics that can be changed as the results of an effect, hitpoints etc. If an effect can only modify one statistic then you would not need a column for each statistic that can change but instead you could just have a column that represents the statistic that will be changed and another column representing how much the statistic will change. Most importantly you will need an ID column.

Then in your separate Abilities table, depending on how many effects an ability can have you could either have a column for each effect, or if you want to support an unlimited amount you could have a column that is a comma separated list. This/these column(s) would store the corresponding ability ID. You abilities would also have a column for a unique ability ID.

Then your card table would have a card ID, name, description as well as columns (or a column with comma separated values) to store the IDs of the abilities of the card.

Then the game could have three different dictionaries for each of these objects. You would load the effects first, abilities second and cards last. You would have a list of Effects in the Ability class. An effect would be added to this list as it is retrieved from the effect dictionary (using the effect's ID).

A similar approach would be used for cards except that cards would have a list of abilities instead of a list of effects.

EDIT: Changed the post so it actually made sense ;)

This topic is closed to new replies.

Advertisement