Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I started working on a Web turn-based PvP RPG game. Now I'm working on the battle system but I encountered some issues:

How can I keep track of everything that happens in the battle? It should keep track of the characters on the field, inventory, the damage done etc.

I first thought I would simply put it in the (MySQL) database, but I think it will be too much. Especially if several people are in a battle. I thought of puting this in sessions or cookies but I don't think thats reliable.

Does anyone have an idea how I can do this?

share|improve this question
Is this a play-by-mail style game? How long do you need to store the "condition" of the battle field and how often does it change? – chaosTechnician Jun 17 '12 at 23:12
up vote 6 down vote accepted

I first thought I would simply put it in the (MySQL) database

Sounds good!

but I think it will be too much.

Then you don't know the limits yet.

Seriously, just throw everything in a database. Don't care about performance too much at this stage, if it becomes an issue you can fix it later.

Here's an abstract view of what your database could look like:

-- id (int, key)
-- name (string)
-- health (int)

-- id (int, key)
-- character_id (int)
-- name (string)

-- id (int, key)
-- name (string)
-- location_id (int)

-- id (int, key)
-- battle_id (int)
-- character_id (int)

This employs something called database normalization, where each unique piece of data is stored once and only once.

Now, if you want to get the names of the participants in a battle, you can use an inner join to combine the data tables. This should explain that:

share|improve this answer
This is great advice, +1 – Adam Smith Jun 18 '12 at 7:22
Hey this is truely great advice! Luckily I know my way around with SQL! Thanks a lot! – Jay Wit Jun 18 '12 at 9:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.