Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

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:

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

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

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

BattleParticipants
-- 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:

http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html

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

 
discard

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.