Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 355147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:59:27+00:00 2026-05-12T11:59:27+00:00

Here’s the lowdown of the situation. I am creating a role-playing game with PHP.

  • 0

Here’s the lowdown of the situation. I am creating a role-playing game with PHP. The combat system consists of the various buffs and debuffs. The combat is likely to take several turns (it’s against an AI).

I am of two mind about ensuring the correctness of the player’s data (buffs and debuffs expire over time. A +5 strength buff may last for only 1 turn). I could

1) Go through a character init sequence which fetch the user’s data and changes to his data from items, equipments, passive skills, and then add in the buff, which is stored in session. If the buff exists, I apply it. If not, it’s gone. This way the correctness of the data is ensured at the cost of performance…I assume.

2) Store the entire character data in session, and update the buffs. When the buffs is active, I add the modifiers, if the debuff/buff is gone, I have to remember to ‘roll-back’ or clean-up whatever effects the buff have. I am assuming this is less taxing on DB but will be difficult to ensure correctness as there may be so many different type of buffs.

So in terms of

a) database overhead
b) maintainability of the combat system
c) industry practises on such cases,

how does the 2 solutions fare? Are there more which I don’t know about? I was thinking of using a subscriber pattern to implement #2, but as the web is stateless that seems to add more overhead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:59:27+00:00Added an answer on May 12, 2026 at 11:59 am

    I’m going to go with “neither” here, and tell you the approach I would take.

    I can assume that because of your question, you’re obviously planning on having some decent traffic and want to make sure your application performs under load. That being said, you should remember the nature of sessions here. If you ever need to cluster your front end by adding multiple web servers to spread out the load, then PHP’s normal file-based session handling becomes relatively useless, as you can’t ensure that a web visitor will hit the same front-end server all the time (well, you probably can, but it would be difficult). Storing to cookie might not be the best bet either if you’re storing game states, as you might have more than 4Kb of data.

    So the next step after that is to move your sessions to a central point with a new handler, which is generally your database. Any database gains you’ve made by storing to session have an offset now, as you still need to hit the database. It might not be quite as expensive, but it’s not ideal. Basically, you’re just bundling up data and re-writing it in a different form.

    The scalability pattern I would follow here would be closest to your #1. Initially, rebuild the buffs each time and ensure data correctness. Use sessions to alleviate some performance, but don’t rely on them heavily. When you start encountering performance issues, you’ll have several options. In likely order of preference, they will be:

    • Install and use memcached. Instead of caching to sessions, cache to memory! Much faster, and a much better performance gain.
    • Separate the database and the web server onto different servers.
    • As you continue to grow, change your session handler to be database-oriented, and add more web front-ends
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is what I am currently doing. PHP echo's out the recent post in
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here's the situation: void funct( unsigned u, double d, float f ) { u
Here is what I am trying to achieve in PHP: I have this string:
Here's the code require_once 'functions.php'; require_once 'cfg.php'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $db);
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my work environment: Eclipse Juno as IDE with maven2 plugin on it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.