Jump to content
  • Advertisement
Sign in to follow this  
Lunar Fenris

TCG Programming Methods

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently trying to create something that will allow you to play a trading card game(Specifically Yugioh), and i'm trying to figure out how to go about the actions and reactions of playing cards. Like playing this card requires that you discard a card from your hand, then you can summon it. Or You play the other card, and you destroy 2 cards on your opponent's side of the field. This all would require that each card has it's own actions, or code. I was thinking of maybe a scripting language, or anything along those lines. But even that i'm not 100% clear on how to go about. Does anyone have any clue what i'm talking about? Any words of wisdom you might be able to share with me? Btw, there's roughly 1000+ diffrent cards i'm going to have to apply unique actions to, so the amount of work into each card will put some influence on this. Thanks :) [Edited by - Lunar Fenris on January 29, 2007 8:05:46 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you have a fixed set of effects and requirements, you can probably just set flags and parameters in the data file, and leave these effects 'off' by default.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravuya
If you have a fixed set of effects and requirements, you can probably just set flags and parameters in the data file, and leave these effects 'off' by default.


Uhm, well how would i go about the effects and requirements? That's pretty much what i'm asking. I'm still kinda new to programming, so i don't know what methods i could use to make those effects and requirements, and make the program respond to that. That's my problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lunar Fenris
Uhm, well how would i go about the effects and requirements? That's pretty much what i'm asking. I'm still kinda new to programming, so i don't know what methods i could use to make those effects and requirements, and make the program respond to that. That's my problem.


First, you need to sit down and figure out all (or a great deal) of the effects that you'll need. You'll then have flags for each effect in the card structure.

i.e.

struct Card
{
int attack;
int defence;

bool spell;

bool invincible;
bool fire_element;
bool water_element;
bool stone_element;
bool impervious_to_spells;
};


So, for instance, if the 'invincible' variable is 'true', then the creature that the card represents is invincible. In fact, you might even go so far as to define a Card base class and then have derived classes for spells, creatures, etc, etc, but that's probably a little too advanced at the moment.

So, run with that for a while and see how you go. But, I'm just letting you know now, in order to keep it flexible, you'll probably be re-writing this a couple of times, if not more, over the development life of the game. But, if you do it properly, it will be an absolute cinch to add new cards, and have those cards be used with no problems whatsoever.

Edit::
Instead of relying on booleans to define your card type, you'll probably want to use enums:

enum CardType
{
CARDTYPE_CREATURE,
CARDTYPE_SPELL,
CARDTYPE_I_DONT_KNOW_YUGIOH_SO_I_CANT_ADD_ANOTHER_CARD_TYPE
};

struct Card
{
CardType card_type;

// everything else
};


// later on in the code
void useCard(Card c)
{
if( c.card_type == CARDTYPE_CREATURE )
// do stuff
else if( c.card_type == CARDTYPE_SPELL )
// do more stuff
}


Did that help?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!