I have finished the bonus system, or buff / debuff system if you want.
There are several types of bonuses, some runs for a certain number of turns and during all those turns it gives a stat change (ex. attack +3). Others runs a random number of turns or actually, a roll is made each X turns and might end the bonus, each X turns the bonus will also do something, usually add or subtract health or mana points.
A bonus can also have a fixed number of turns and when they are finished, a percentage of risk (or chance if it is, say, a venom) of dissipation.
It wasn’t particularly complicated but it was actually more complex and took longer than I had thought, this is what I had to create:
- Reference bonuses and its table in the database
- At player logout save off players bonuses in the database, in a “running bonus” table
- Create that running bonus table
- At player login, load up old bonuses and set them to work
- Function to create a bonus ingame and thus store them in an array or so
- Run the bonuses when player or NPC spends time
- Send bonuses to player at bonus creation and login
- Send updated or deleted bonus to player
- Show the bonuses ingame
- Make graphics for the bonuses
- Recalculate and send all the stats when bonuses are created, deleted or changed
- Make items give the player a bonus when used
- Kill the player if a D.O.T (damage over time), euh, kills the player
- Clear all bonuses when (well, if) the player gets killed
Well, it is all done now so go and enjoy that happy snake bite or attack bonus!