Chapter 9. Online Gaming
This chapter outlines the basic patterns and principles for using MongoDB as a persistent storage engine for an online game, particularly one that contains role-playing characteristics.
Solution Overview
In designing an online game, there is a need to store various data about the player’s character. Some of the attributes might include:
- Character attributes
- These might include intrinsic characteristics such as strength, dexterity, charisma, etc., as well as variable characteristics such as health, mana (if the game includes magic), etc.
- Character inventory
- If our game includes the ability for the player to carry around objects, we’ll need to keep track of the items carried.
- Character location/relationship to the game world
- If our game allows the player to move their character from one location to another, this information needs to be stored as well.
In addition, we need to store all this data for large numbers of players who might be playing the game simultaneously, and this data needs to be both readable and writable with minimal latency in order to ensure responsiveness during gameplay.
In addition to the preceding data, we also need to store data for:
- Items
- These include various artifacts that the character might interact with such as weapons, armor, treasure, etc.
- Locations
- The various locations in which characters and items might find themselves such as rooms, halls, etc.
Another consideration when designing the persistence backend for an online ...
Get MongoDB Applied Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.