Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize/deserialize player data to/from JSON #107

Open
tagniam opened this issue Oct 3, 2020 · 5 comments
Open

Serialize/deserialize player data to/from JSON #107

tagniam opened this issue Oct 3, 2020 · 5 comments

Comments

@tagniam
Copy link
Owner

tagniam commented Oct 3, 2020

Currently we save player data by writing raw values line-by-line in data.txt. It looks something like this:

1
Dude
M
11
10
89
35
2
9
18
78
401

We'd like to change the player data parsing code so that it supports reading from and writing to data.txt in JSON format, which should be changed to look something like this:

{
    "player_type": 1,
    "name": "Dude",
    "gender": "M",
    "level": 11,
    "experience": 10,
    "health": 89,
    "arrows": 35,
    "bombs": 2,
    "potions": 9,
    "whetstones": 18,
    "weaponstrength": 78,
    "coins": 401
}

This way it is much clearer what the player's attributes are by looking at data.txt.

Feel free to use a JSON parsing library, though preferably it should be lightweight and header-only!

@captaincrunch21
Copy link

Hey!
I can solve this. I will rapidjson. It's header only and lightweight. How big the save file will be? And are keys predefined or can they be created by user on the fly?

@tagniam
Copy link
Owner Author

tagniam commented Oct 3, 2020

The save file is small (see the example in the issue) and the keys are predefined, however developers might add more keys in the future if we add more player attributes, so the code implementation should be flexible enough to support that.

@pallavi267
Copy link

hey i want to work on this is the enhancement open?

@tagniam
Copy link
Owner Author

tagniam commented Oct 25, 2020

@pallavi267 yup it's open!

@pallavi-bits
Copy link
Contributor

Please assign it to me, i want to do this.

@tagniam tagniam mentioned this issue Oct 27, 2020
Closed
@DJ73 DJ73 mentioned this issue Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants