Card game engine?
Moderator: Coders of Rage
-
- Chaos Rift Regular
- Posts: 101
- Joined: Thu Dec 09, 2010 2:13 am
Card game engine?
What would be the best way to store a large amount of "cards" like magic the gathering cards or similar. Each card would have various stats and maybe an effect, and then be sortable into a deck which is randomized for battle.
I was thinking of using a large amount of arrays, but there has to be a way to store the cards data that i'm overlooking, as the ways I have thought of seem terrible.
So basically, I'd like to know the best, or most effective ways to create a card game engine.
I was thinking of using a large amount of arrays, but there has to be a way to store the cards data that i'm overlooking, as the ways I have thought of seem terrible.
So basically, I'd like to know the best, or most effective ways to create a card game engine.
-
- Chaos Rift Regular
- Posts: 101
- Joined: Thu Dec 09, 2010 2:13 am
Re: Card game engine?
Ah yes, it'd be C++ with SDL/GL. Forgot to mention that.
-
- Chaos Rift Cool Newbie
- Posts: 70
- Joined: Mon Dec 13, 2010 10:55 pm
Re: Card game engine?
Going from this, I'd also suggest a deque, as it's most relative to an actual deck of cards. You can push and pop things from the "top" or "bottom" of a deque, as well as access individual cards in the deck.XianForce wrote:If you're using C++, I'd recommend a map
I'd also LOVE to see the finished product. I'm a huge advocate of card games online, as they can allow for much easier access to new cards, and far better organization. Just Chaotic was stupid as fuck >.>
-- Jesse Guarascia
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
-
- Chaos Rift Regular
- Posts: 101
- Joined: Thu Dec 09, 2010 2:13 am
Re: Card game engine?
I'm thinking of using vectors for the deck. I really just want a great way to store the raw card data. Like it's name and stats and what not.
-
- Chaos Rift Cool Newbie
- Posts: 70
- Joined: Mon Dec 13, 2010 10:55 pm
Re: Card game engine?
A vector, deque, and map are almost completely identical. A map allows for access by a Key (int, string, whatever you want), and a deque is a double sided stack (essentially). Both of these are better alternatives for this sort of thing. I don't see why you're fixated on vectors. Besides, using the alternatives we gave you would be beneficial, as you wouldn't have to write some container methods and cycle through each member of the vector to tell if it's the one you really want.
-- Jesse Guarascia
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
-
- Chaos Rift Regular
- Posts: 101
- Joined: Thu Dec 09, 2010 2:13 am
Re: Card game engine?
I know this. I said vector meaning deque.
-
- Chaos Rift Cool Newbie
- Posts: 70
- Joined: Mon Dec 13, 2010 10:55 pm
Re: Card game engine?
Oh my apologieslike80ninjas wrote:I know this. I said vector meaning deque.
-- Jesse Guarascia
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
-
- Chaos Rift Regular
- Posts: 101
- Joined: Thu Dec 09, 2010 2:13 am
Re: Card game engine?
Like I said, I think I have the whole deck idea down, I just want to know some good ways to store the data of cards.
The data would be static except for negative effects from gameplay, so I'm thinking of making some sort of static card list and copying the data out of it to the actual "cards" used in the game.
The data would be static except for negative effects from gameplay, so I'm thinking of making some sort of static card list and copying the data out of it to the actual "cards" used in the game.
- wtetzner
- Chaos Rift Regular
- Posts: 159
- Joined: Wed Feb 18, 2009 6:43 pm
- Current Project: waterbear, GBA game + editor
- Favorite Gaming Platforms: Game Boy Advance
- Programming Language of Choice: OCaml
- Location: TX
- Contact:
Re: Card game engine?
I'd say store the data for each card object in map. Then have a map from card name to card object.like80ninjas wrote:Like I said, I think I have the whole deck idea down, I just want to know some good ways to store the data of cards.
The data would be static except for negative effects from gameplay, so I'm thinking of making some sort of static card list and copying the data out of it to the actual "cards" used in the game.
For cards that will then be used in a deck, you can have a collection (vector, stack, etc.) of maps containing the name of the card represented, as well as any changes to the original.
Edit: If every card has the same types of attributes, I would create a card class/struct. If each card has different types of attributes, I'd use a map.
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Card game engine?
I would use STL map to represent the objects in the engine. You can store all of the card information in a SQL database. This way you can easily query for the cards relevant to the current game then load the data into the map.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: Card game engine?
If you have a large number of cards and you want the game to be easily expandable then this is porbably a good idea.dandymcgee wrote:I would use STL map to represent the objects in the engine. You can store all of the card information in a SQL database. This way you can easily query for the cards relevant to the current game then load the data into the map.
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup