I'm working on a text based mmo right now. Now, I hope this is advanced enough to go into this forum, I would consider myself a somewhat intermidiate php programmer for most tasks, but I'm not sure what would be the most efficient way of making this engine.
Essentially, I want the user to be able to choose a group of creatures to fight, or a "monster group". These monster groups would be taken from the database and put in a select menu; eg. <option>3 Dragons</option> etc. etc.
When you get into the fight, all three (in this case; the number of creatures would vary between encounters) of the monsters would have to have a different health number, different offensive and defensive stats, resistance to various spells and so on. All this could be stored in a table called "Creatures" on the database.
I'm wondering what would be the most efficient way of creating a system like this; should I store the creature's current health in sessions, then just retrieve their other stats from the database? Or create a new table called "fights" and have this store the health for all the creatures (which I assume would have to store all the creatures Id's as well as their current health). Or maybe I'm missing a miraculous php feature that could solve this whole issue?
Thanks in advance.
Text Based Fighting Engine
Moderator: General Moderators
Re: Text Based Fighting Engine
You can get it working either way, but it depends on to what extent you need persistency. If a user quits during a fight and rejoins the next day, should they be able to continue their fight? Or should they be able to login from another computer and continue a situation abandoned earlier? In that case, use databases.
Re: Text Based Fighting Engine
Thanks for the reply.
I think I will stick with not storing the monsters health in the database, as to not have many users changing this value every 2-3 seconds, which is probably just going to put a lot of strain on the database.. That and persistency is something that I don't want at all; so it would be easier to just get rid of the session variables from the fights as they end rather than having to take out the row in the database.
I read something that explained it nicely - use sessions in this case like RAM to store information on whats currently going on in the game, then use the database like the hard disk for any permanent changes.
I think I will stick with not storing the monsters health in the database, as to not have many users changing this value every 2-3 seconds, which is probably just going to put a lot of strain on the database.. That and persistency is something that I don't want at all; so it would be easier to just get rid of the session variables from the fights as they end rather than having to take out the row in the database.
I read something that explained it nicely - use sessions in this case like RAM to store information on whats currently going on in the game, then use the database like the hard disk for any permanent changes.
Re: Text Based Fighting Engine
That works but dont overdo it on the sessions - too much in the session can create memory issues later on (especially if you have thousands of people on your site concurrently).