herobank110 / factorygame

Python game engine to have a 2d movable "graph".
https://factorygame.readthedocs.io
MIT License
1 stars 2 forks source link

savegame system #5

Open herobank110 opened 3 years ago

herobank110 commented 3 years ago

SaveGame objects with serialisable properties that can be saved and loaded into save slots

p4mela-g commented 3 years ago

I'm interested in trying to do this and if everything goes well, also in opening a PR during Hacktoberfest. :)

herobank110 commented 3 years ago

Hi, thanks for your interest!

Let me elaborate in the issue. It is for a data saving and loading mechanism for games, such as the last checkpoint, player name, high score, etc.

I was thinking of 2 new functions: saving function - input: dictionary to save, slot name, output: whether the save was successful loading function - input: slot name, output: dictionary of saved values, or None if the slot couldn't be loaded If you have other suggestions please let me know.

A good place for this would be as static methods of GameplayUtilities, under factorygame/utils/gameplay.py

My initial idea was to have a SaveGame class to add fields to in a derived class, so you could have autocomplete on the loaded save game object, but this should be a separate issue.

p4mela-g commented 3 years ago

I was thinking about the same approach of two new functions to save and load. I really want to work on this challenge, I found your project very interesting =)

herobank110 commented 3 years ago

Thanks. I assigned you to the issue!

p4mela-g commented 3 years ago

hello, sorry for the lack of news. this week I start working on this problem :)

p4mela-g commented 3 years ago

can i use any library?

herobank110 commented 3 years ago

what library were you thinking of using?

p4mela-g commented 3 years ago

some library like Pickle

herobank110 commented 3 years ago

Certainly, anything in the standard library is fine. Other libraries might be difficult to link as the package doesn't currently have a setup.py. If you do use pickle please consider Protocol version 3 which is compatible with python 3.2, the oldest version of python currently supported by this project.

p4mela-g commented 3 years ago

Do you think about supporting python 3.7+ in this application?

p4mela-g commented 3 years ago

This is what I'm doing:

In the save / create method, I check if the folder containing the savegame exists, if it does not exist, it is created. In order not to have problems with overwriting files, I think of using a standard name like "savegame_nowtimestamp.dat". In the load method, I think about checking if the file you want exists, and if it exists, I load the data. In both cases, a message will be sent to the user if the action was successful or not.

If you are dissatisfied with any of the steps above, tell me and I will do it the way you think is ideal. :smile:

I'm having a little trouble finding where to collect the data to be saved on the savegame.

herobank110 commented 3 years ago

Great work! Sounds like you have a lot of functionality.

I have a few ideas for you:

The data that should be saved you have two options:

I definitely want to support python 3.7+. Someday I will drop 3.2 support and make 3.6 the oldest supported.

p4mela-g commented 3 years ago

Sorry! I had some issues with my OS and I ended up losing progress before I could commit. I'll start over.