DISQUS

Building Browsergames: Building Browsergames: Healing your players (PHP)

  • obat jerawat · 8 months ago
    thanks for the info, I will try it now ...:D
  • Rick · 7 months ago
    Hi! Firstly, I'd just like to say thank you for putting this site together. Its truly awesome and has given me a bit of a kick to actually stop thinking about doing something, and actually doing something!

    Secondly, on line 28, you poll the database to get the current gold count, yet on line 20 you've already done this and not changed it. Wouldn't it be more efficient to insert a line above 28 such as:
    $gold = $gold - $amount;
    and then change the setStat to:
    setStat( 'gc', $userID, $gold);

    You could do the same with the actual healing value as well. Avoid two calls to getStat('curhp',$userID) as you've already got that value.

    From a performance point of view wouldn't this be better?
  • Luke · 7 months ago
    That'd definitely be better for the sake of minimizing database hits - while
    I was building these scripts, I'm afraid they sort of grew organically, so
    optimizations that should have been made sometimes didn't.