Page 2 of 2

Re: General tutorial on programming a CCG?

PostPosted: 09 Jun 2012, 21:21
by magicgrove
@mageking17, @silly freak
Most of these cards are indeed though to implement.

The game just has so many cards and is fun even with just a portion of them. Even with easy cards the whole thing takes a lot of time before you get something that resembles a 'decent' game :), so my advice would still be to start simple.

Re: General tutorial on programming a CCG?

PostPosted: 10 Jun 2012, 00:16
by melvin
Although I've not started a CCG program before, I tend to agree with magicgrove. There is the danger in being too ambitious at the start and trying to factor in all sorts of complicated scenarios.

As magicgrove mentioned, an important milestone will be just having the whole game working, even if it is only with simple cards. This gives the developers a huge sense of accomplishment and something that they could potentially release for others to try while they continue to enhance the engine, add more card etc.

Re: General tutorial on programming a CCG?

PostPosted: 10 Jun 2012, 09:18
by silly freak
Just in case I was misunderstood the first time, I want to clear some things up: I agree with you!
The first version basically has to support only basic lands and vanilla creatures. This means you have playing lands and spells, plus the mana pool, as well as turn structure, including combat, and win conditions. This is more than it sounds!
When you have reached that, I would look into simple abilities like Llanovar Elves, Shivan Dragon, and maybe Verdant Force. The last one is a triggered ability, which is (in my architecture, at least) a little trickier than activated ones (plus you already got working basic lands, so no problem with activated's at all maybe), so you might want to do it later. I'd probably add Wrath of God there, but not Shock and Volcanic Hammer; these have targets, and getting targets right is hard. Same goes for Blanchwood Armor, except that Auras are an additional Hard.

But what you see here is that every time you skip something because it's hard to do, you might come into the situation where you simply can't add it afterwards. So, just because you skip targets for now, don't code without thinking where they will interact and what you need to know to do them right.
And while you're thinking, think about how your damage system might work with Wither, Infect and Lifelink? You don't have to add it yet, but if you don't see how you COULD do it later, try to change your damage system right from the start.

So the cards we stated is a good "think about it" set, not a good "start with these" set. And you're GONNA reach the point where you have to start over, but not as often, because in each iteration, you can focus on multiple things and make multiple things work.

Re: General tutorial on programming a CCG?

PostPosted: 11 Jun 2012, 05:45
by MageKing17
silly freak wrote:And while you're thinking, think about how your damage system might work with Wither, Infect and Lifelink
And deathtouch! Shouldn't forget that deathtouch isn't a triggered ability, any more; the Magic 2010/2011 changes resulted in quite a few headscratchers, as far as combat logic was involved.

Re: General tutorial on programming a CCG?

PostPosted: 05 Jul 2012, 15:48
by txitxo
Disclaimer first: I am a computer engineer, have done a fair amount of OOP programming but have never tried programming a CCG. As a bunch of people here actually have, whatever they say I stand corrected :D I am purposely simplifying some stuff so dont' be too harsh :P

Formedras wrote:Actually... it's not the variance that worries me. I'm not looking for anyone to tell me what my game's rules should be, since I'm not making a clone of a CCG, but rather a fully-original one. Anyway, that's still easy: tell the game server to wait for events (commands from the clients) and react to them. (Yes, the server. I don't think a P2P model is a good idea; just try to allow both sides to hold and change the game state and keep them in sync. Not gonna happen.) Any programmer should be able to figure that out once they figure out the other parts and events. If not, they probably shouldn't be programming.
Plus... a guy's got to learn somehow. Better a guide that goes a bit over the user's head than pure source without a guide that goes orbital in relation to the user's head.

Anyway, here's what I think should and shouldn't go into a guide like this.
What I'm looking for in a guide:
1. How to set up cards, decks, and players.
2. How to set up turn steps and turn order for a given category of objects, not necessarily players. Players would obviously be the default for most games, but allowing it to be different objects may make things better in the long run, both for the guide and the programmers using the guide.
3. How to create a server to handle the game state and how to connect the clients to it. Obviously, this would involve networking.
4. An Object-Oriented language, using events as the driving force for progressing the game forward.
5. A way to use text and/or markup language (XML, perhaps?) files to provide cards instead of hard-coding them.
6. How to let cards, server-side of course, perform actions.
7. How to set up a basic client, using whatever GUI the language and programming library/framework prefers or otherwise uses.
8. The KISS principle. Some of the other things look like they'd violate this (Client-Server model, anyone?), but I think I've got the requests as simple as they can be while still being usable.

What I'm NOT looking for:
1. A specific programming language. By this, I don't mean "don't use any language", and I also don't mean "don't stick to this language that you know." Probably best to stick to a single programming language (maybe plus a markup and/or scripting language), but whatever the guide designer is using is probably best for now.
2. A specific CCG as a guideline. See point NOT-1. Magic would be the obvious starting point for a guide, but I personally think it's too limited; however, if it works it works.

All considered, I think a wiki/guide format would be best for this. A non-wiki guide would either look bad or mostly like a wiki anyway, and a straight-up tutorial would give every user the same result, which is the exact opposite of what I wanted.

I honestly think this could work. Hellfish is probably right about this being too much for a truly fresh programmer, but ones that have the basics down and need to learn about intermediate concepts like custom Events, Interfaces, Components, etc. could use this.

My experience in useful programming, by the way, is limited to creating basic life counters for Android (thus using Java/Dalvik), and a twin-stick PvP shooter using C#/XNA. (Like Net Rumble, but I had no clue about that source example until yesterday, while I had made my shooter back in December.) In other programming, I've tried to learn C, C++, Python, VB6, and Java, and I'm taking a class in VB 2010, but for one reason or another I've ditched every language I've tried. (Yes, I will go back to C++ when it's time. And I get the feeling that the time will be somewhat soon.)

If you're still here, thanks for reading. Please, reply about what you think of the possibility of making a guide.
I'll try to give you a few pointers, but Onto the points you mention:

1. Set up can mean many things but basically you want Objects. So a Deck object will be a data structure made up of card objects.
2. I'd say state machine here, but I'm sure there are other ways of doing this.
3. Like any other server. Sorry to be vague but there are so many considerations I can't even start on this one. It pretty much depends what you actually want the server to do and how you want to do it since it doen's even need to be in the same language/OS/architecture...
4. Don't see the question here. Yes? There are other kind of programming languages which you might be able to use (I bet procedural could potentially awesome), but stick to OOP, way more documentation and examples, especially for game.
5. XML parsers. Thay are included in every standard API I can think of. Also for JSON, CSV...
6. Don't know what you mean by this... Client would send a message to server and server would reply with actions to be shown. Same as any other client-server architecture.
7. There's two differentiated parts here, setting up the GUI and connecting to the server. Ton of options here, depends on the programming language. Then choose a library for the GUI (depending if you want 2d bitmap, 2d vector, 3d...). Connectivity wise, probably the included API is enough.
8. HAHA. CCGs in general do anything but keep it simple. That's why most advanced programs can't do certain cards.

Hope this helps and opens some rabbit holes for you to look into, but it seems to me you might want to start with something WAY simpler than a CCG. Try doing a poker game. There's a ton of tutorials out there in many languages and should give you a basic overview on how to organize your program. You can even probably find some online functionality. Then start tweaking, maybe trying some other cards games. Best of luck :D

Re: General tutorial on programming a CCG?

PostPosted: 15 Jul 2012, 18:14
by MageKing17
I just have a couple things to add...
txitxo wrote:5. XML parsers. Thay are included in every standard API I can think of. Also for JSON, CSV...
I'm not a huge fan of XML; I call it a solution perpetually in search of a problem, and haven't found it particularly useful in any situation, let alone CCGs (indeed, Firemox is a Magic program that has XML-defined cards, and the card format is distressingly limited... or, rather, it was the last time I looked at Firemox, which was over four years ago). I've found it's almost always easier to make a data file format (or repurpose an existing one) that applies to your specific project much more helpfully than XML, and is both more human-readable and more machine-readable... but I'll grant I'm hardly an expert in the area. As txitxo said, if an expert disagrees, I stand corrected.

txitxo wrote:Hope this helps and opens some rabbit holes for you to look into, but it seems to me you might want to start with something WAY simpler than a CCG. Try doing a poker game. There's a ton of tutorials out there in many languages and should give you a basic overview on how to organize your program. You can even probably find some online functionality. Then start tweaking, maybe trying some other cards games. Best of luck :D
I can definitely vouch for writing a poker game being a good programming exercise, for anyone; I once added poker functionality to an IRC bot, and getting the logic for that kind of asynchronous gameplay environment down (not to mention the rather complicated hand-comparison function) was a challenge that taught me quite a few things.

Re: General tutorial on programming a CCG?

PostPosted: 26 Jul 2012, 04:16
by Formedras
Alright, I know it's been a while since I was actually here. Sorry for not replying to this stuff. Although... I will say that I'd like to keep M:tG-specific talk to a minimum. I really don't care to make my own Magic clone. There's almost no programming problems that are limited to that game. (Though I will say one thing: colored mana could be represented by a flag-based enum. This allows for extensions into dual-colored mana and Phyrexian Mana pretty easily.)

I'm now going to an Art Institute, in the Game Programming major. I've been going for the last year, and my game CardGrid has taken quite a backseat in the meanwhile. Not gonna pretend that I've actually been working on it, though I did reprint some physical cards to card stock in anticipation of testing the game again. I've been pretty disoriented, and my psychological state has somehow deteriorated since last I posted here. Not sure how I'm not in a mental institution.

Umm... back to relevant stuff...

I really do need to build up a wiki guide for programming concepts needed in CCGs. As long as I know I'm not getting meaningful help, I think I should probably do it privately hosted (as in not on the Internet) to start it, then upload somewhere else once it's ready for viewing. (As such I'm actually downloading XAMPP and MediaWiki right now.)
Just to let you know, I'll be primarily doing it in C# and Python. I've decided that, at least in some cases, specific programming of cards is necessary. But doing it in Python gives the ability to change things on the fly. (Replace the .py and give the C# server a "Recompile" command. Or the TCG server could do it itself from an HTTP upload.)
Haven't quite figured out... pretty much anything else. Or even that stuff above.

As before, please correct me - QUICKLY - if I said something stupid or otherwise wrong.