Creating Player accounts

Hello All, I’ve been able to make a login/register system using code, no databases, just storing it in a file. Now I want to move further on. Creating player accounts. Where it stores all your data.

I’m 100% sure you’ll all tell me to refer back to Brackey’s tutorial on creating User Accounts. I don’t really wanna use a Database for this. I just want to store all data in a file. As I’ve done for registering. Is there a way, just using code. And partly because I didn’t use any database for user accounts.

Even If I change my mind and want to start using a database. Will I also have to change the login/registering system, so that will also have to use a database or will it not clash together?

Whether or not you’re using a database you need to abstract your code into separate responsibilities:

  • The code that performs logins and registrations
  • The code that read/writes your data from persistent storage

If you separate those things into separate classes, it will be easier to later swap to a database because you will only need to change the code that performs the reading/writing from a file to a database. The rest of the code (that does the registration) would remain unchanged.

That make’s sense. So I can assume it is possible to create accounts and storing the data without using a database.

For now I just want to store like player coins, gems and other things like that. Right now I just want to set these things. when a Player registers it set’s it’s amount of gems etc. And saves it.

If it were you, would you use a database, if yes. Which one?

I also want to see if it works. I’ve already worked on a shop so I want to see if player can spend gems and that it also save’s the updated gems on that account.