Sign in to follow this  
FlashbackJon

[web] Turn-based battle...

Recommended Posts

I'm building a game that runs via PHP/MySQL (with a hint of javascript and Ajax). The easiest comparison to make is that it is ultimately like *shudder* Pokemon. Players have a stable of monsters and issue challenges to other players in order to engage in turn-based battles that net experience. The trick is that even while engaged in battle, they can do other things with their monsters and possibly engage in multiple battles at once. I'm also trying to figure out the best way to manage fights from multiple monsters, and keep a tally at the player console of what fights they are engaged in, and what fights are waiting on their input. I don't want increases or upgrades that occur outside the fight to affect a fight already in progress. Here are my thoughts on table design, and I'm looking for feedback. I already have a pretty sizable `monsters` table, containing all their base stats. I'm looking to create another table called `battlestats` that stores snapshots of the appropriate stats as the fight goes on. I'm shying away from retaining "historical" snapshots, so just one record per monster per battle. This is the big question: essentially, it seems like a lot of unnecessary copying, but I can't think of a better way to do it. Finally, as far as battles, I'm thinking a `battles` table with only the basics in it, and a `rounds` table that actually records what occurs during the fight. Thoughts? Recommendations? Need additional info?

Share this post


Link to post
Share on other sites
What is the big question? You said 'this is the big question', but didn't ask a question. :P

If a monster can be in multiple battles at once, then you have to know how you're going to resolve that monster's state when both battles conclude and probably disagree on that monster's final state.

Share this post


Link to post
Share on other sites
How about locking out a monster that is in a battle. You can have a variable in the MySQL DB that is set to TRUE whenever the person is in a fight and sets back to FALSE when they are done. That was if the player is challenged while in a fight the challenger will get a message. To prevent disconnects from making the variable = TRUE on system disconnects when battles are not completed, you can make sure the variable is set to FALSE on login.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this