Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial implementation for a version update framework to get the ball rolling a bit.
When updating games to newer versions with new/updated content, it might be necessary to modify the save file a bit to match the new game implementation. Some examples of this include:
This PR is to allow users of IGT to implement version updates for their game.
We've added two new
protected
properties toIgtGame
.version
will be a semantic version string to match the game's current version. This will need to be updated with the game by the user as their game is updated.saveUpdate
will be an optional property in case the user doesn't want to implement a version update framework for their game (if the game is simple enough and won't have any new updates).the
saveUpdate
property is defined as a newIgtSaveUpdate
abstract class. This will be extended by the user to implement their ownversionUpdate
callbacks, which is dictionary of semantic versions associated with an update callback function that will update the save data for that version.Additional Areas of Development
Currently the version update handling is bare bones. There isn't any handling for errors/crashes on updating the save data, which might cause the game to not load properly if there is an invalid save update.
The
saveData
is defined inIgtGame
asRecord<string, unknown>
, which isn't exactly helpful when handling the version updates as nothing is defined in TypeScript. However I believe this is probably the best implementation/shouldn't be touched. as strongly defining the save means that older version updates may become broken as the save structure evolves. The downside is that having a undefined save structure can lead to fairly obscure update code and is prone to errors.There might be common version update logic that could have pre-built helper functions implemented. A couple of examples:
I haven't used this implementation yet (mostly because it's not part of the library yet :) ) so we'll see how much this needs to change.