So i’m working on a TCG and i’m using XML for the card database. each card contains 25~30 variables of string/int/bool. in a set of 200 cards thats 5000 ~ 6000 variables in a single XML file. I’m concerned about loading speed if there is more than 1 set of cards are in the game(for example 3 sets = 600 cards = 18000 variables to load) should i separate the file to multiple ones? I just want to hear some comments and thoughts about this.
<?xml version="1.0" encoding="utf-8"?>
<CardCollection>
<Name> CardSetName </Name>
<Cards>
<Card id="1">
... bunch of card data
</Card>
<Card id="2">
... bunch of card data
</Card>
<Card id="3">
... bunch of card data
</Card>
......
<Card id="199">
... bunch of card data
</Card>
<Card id="200">
... bunch of card data
</Card>
</Cards>
</CardCollection>
If it’s a database why not use an actual database? There are pretty small and lightweight ones around that could be used for this.
That aside, I’d personally put each deck/collection in its own file if I were to use XML for this kind of thing, assuming that you don’t necessarily need all collections loaded at all times.
I agree that a database should be the most suitable solution. That said, if you assume each variable weighs, say, 10 bytes on average, this still won’t consume a lot of memory. It might make sense to just load the entire card database into memory at startup and store it in a map. When you load a deck, you could just get the card id numbers and fetch the card data from the array. Xml should be fine unless your database is ridicilously large.
@angrypenguin i’m not very familiar with other databases. all i know is MySQL which will be used for player username and account info. i dont see any reason to load the card database onto it.
@chjacobsen i thought about that too, loading the entire card database into memory at startup and when loading a deck just use card id numbers. I thought for now the first expansion/set of cards is around 200 cards which isnt really big and should load rather quickly. but what about later expansions? a few sets down the road would loading the cards at startup start causing issues?
If we assume each set is 6000 values, that each value equals 10 bytes and that you have a budget of, say, 1mb. Each set would use just below 60kb. You could add 15 expansions, or 3000 cards, with some margin to spare. I really doubt you are going to have a problem.
thanks alot for the comments and thoughts. i dont think i have any worries then.