Taking care of monsters
Now the game starts to get interesting. There is, however, one small thing missing. If one player kills a monster, it will only be dead for him and not for all the other players. This can be fine in some very special cases, but most of the time this is not what we want.
The solution is to implement the logic that takes care of the enemies and the fights server side. This means that we need another database table that will hold all of our enemies. This table will need to hold the following information:
The ID of the enemy, to identify it uniquely
The type of the enemy—a skeleton, an ogre, and so on—to define how it will look to the player
The x and y coordinate of the enemy
Its life to allow the player to kill it
Its defense for the combat system
Its spawn rate to determine when the monster should be spawned again once it has been killed
Then, periodically, we will transmit to the clients the position and properties of those enemies. As we already have a page that is being...