Sign in to follow this  

Customisable Card Game Design

This topic is 4414 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 thinking of writing a game so I can play my favourite (but old) CCG against the computer (finding human players has gotten REAL HARD (tm) recently, 'cos they're only interested in playing the latest game). Because of the nature of CCGs, every card has a unique effect on the game. I figure there are two possible ways of implementing this: 1. A generic Card class, with subtypes for each type of card (e.g., Characters, Equipment, Locations, etc.). To implement each card's unique characteristics, use a script that is parsed whenever that card could affect or be affected by the game. 2. Sub-class everything, so that every card eventually has its own class which encapsulates that card's unique properties. I suspect #1 is the best way, but I was wondering what everyone else thought. Anybody done something similar?

Share this post


Link to post
Share on other sites
You'd need to edit the code every time you added a card if you went with 2.

The data driven approach (1) might be harder in the short term, but you'll appreciate the beneift of it in the long run.

Share this post


Link to post
Share on other sites
Thanks, that's what I thought. Are there any existing scripting languages I could use/modify for this, or is it something I'd have to build from scratch (which could be an interesting project in itself)?

Share this post


Link to post
Share on other sites
XML should be fine for what you're talking aboot unless there's special card effects on many cards. In that case, Python or another OO scripting language might help.

Share this post


Link to post
Share on other sites
Quote:
Original post by poss74
Thanks, I'll investigate those. From what I know about XML, I can't see how it'll help me, as each card as a unique effect on gameplay.

But I'll keep an open mind!
This is interesting, as I'm working on a similar kind of program.

As far as scripting languages go, Perl is one of the best, and is meant for parsing files and making data structures. I always ran away from hashes in C++ and Java, but Perl makes them so incredibly easy to use. Python is also very similar to Perl, and is thus worth checking out. (Perl and Python programmers often feud since they both have such loyal followings and each think their scripting language is better!) XML is really more about structure and presentation of data as well as interoperability with HTML. Even if chosen for a card text database file, which could easily get very big very fast, all the repetitive tags may only contribute to the file size.

As far as playing against the computer, writing AI could be tough for CCGs. You may need to write AI for many specific types of game deck strategies. But all in due time, right? :)

As for what I'm doing, I'm taking a vastly different approach than most CCG programs I've seen out there. Instead of hard coding the various unique cases of cards (which can become cumbersome and lengthy) I'm taking a very dynamic approach and instead analyzing the cards lexically.

What I'm doing is searching for keywords, finding their parameters, and then applying them to the game. This may sound Herculean since it requires somewhat strict consistency and order in how rules are written, and perhaps it is a little ambitious... but the reward would be not having to write cases for a huge number of cards, allow future compatibility with new cards (excluding updated card errata, major rules changes, and new card mechanics, of course), plus give people the ability to more or less create their own cards.

I took a class in college where we used flex and bison for testing files for correct syntax, and it's perfect for this sort of thing. Bison is used in the real world in parsers for computer languages, but if you know the rules and how they're written for a particular CCG, then this is a perfect fit. (I know there is a Java version of Flex/Lex and it may even include support for Bison/Yacc rules, too.) I may in the end be able to do without it, but I'm thinking this might be a shortcut worth taking.

Share this post


Link to post
Share on other sites
Thanks Martin, that gives me more food for thought.

I thought about the hardcoding option, but also came to the same conclusion as you -- "cumbersome and lengthy" indeed!

I think I'll follow your idea of lexically analysing the cards. It helps that there are very few cards that affect more than one phase of the game -- a card that has a special effect in the deploy phase probably does have any special effects in battle, movement or end-of-turn (of course, I'm sure there are some that DO have multiple effects, so I'll have to cater for them somehow).


Cheers,
poss

Share this post


Link to post
Share on other sites

This topic is 4414 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this