Skip to content

New savegame system #145

@Xenega

Description

@Xenega

Related: #52 #56 #122
PR: #123 #144

Ok, let rewrite the savegame system.

1/ Separate mutable and immutable data.

Locations, events and techs use the same class for its mutable and immutable data. We must separate it the same way others class separate it, i.e. with XClass.

TODO:

  • Migrate data to LocationClass, EventClass and TechClass
  • Add Location, Event and Tech list to Player

1-bis/ (Optionnal) Rename XClass and self.type.

This is ill-named and create confusion. I would personally go for XSpec and self.spec.

2/ Update savegame with new data.

If 1 was correctly executed, this will be simple. We need to update list in Player. However, the complex stuff happen when we remove things. Two solutions :

  • Nice way: We create rules and special data to handle the suppression.
  • Brutal way: We remove everything. If the user have no base, we recreate a University Computer.

TODO:

  • Update Player the nice way or brutal way.

2-bis/ (Optionnal) Remove computed value from savegame

We should not save everything but real mutable state. Everything that could be computed should not be included. We should do the inverse of the current state which is modified after each trigger, and instead fully re-compute the state after each trigger. It allows to take into account every change made after the savegame.

TODO:

  • Remove computed value from savegame.
  • Re-compute everything that can be (bonus, ...).

3/ Correct the old savegame.

The old savegame need to be correctly reloaded. A problem found is that pickle use string where we use now unicode. Others problems could be hidden.

TODO

  • Replace string with unicode.

4/ Create the new savegame

Basically, we need two things:

  • A small header to contains metadata.
  • The savegame data with its format.

I wanted personally to use String + Json with GZIP. The metadata need to be parsed quickly, so string is good and we can limit the number of characters allowed. Json have the advantage to have no dependencies needed. GZIP allows to reduce the size of the savegame and are sufficiently fast.

TODO

  • New format: String + Json with GZIP
  • New metadata: Date and difficulty.

Conclusion:
The problems with the current savegame is multiple and difficult to solve with few commit. So, I thought to add a new branch to handle all of it and allows other to work on it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions