Adding data persistence to the game
If, like me, you can't imagine a game without a save option, this part couldn't interest you more. In this final part of the book, I will introduce you to the persistence of data. Data persistence is the ability of a program to save its internal state for future restoration. This is exactly what a save option does in a game. In our particular case, because the client received data directly from the server, all the jobs have to be done on the server part. First of all, let's think a bit about what we need to save:
The entities and their components
The teams
The games
We then need a way to store that data to be able to restore it later. The solution is to use files or something else that can grow with time, as easy to copy. For this functionality, I've made the choice of using
Sqlite
. This is a database engine available as library. More information can be found on the website at https://sqlite.org/.
The usage of a database engine is a bit of overkill for our...