-
Notifications
You must be signed in to change notification settings - Fork 8
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
Version Updates #63
Comments
I'm curious how you'd handle the case of depreciating a property but still requiring it for the version skew update. So if I have In the |
You're right, the old data structure doesn't exist anymore. So I think your only action is to cast it to data.exampleFeatureTwo.newList = data.exampleFeatureOne?.listOfNum Although I just realized another possible problem, if you move the same object 2 times: versionB() {
// This featureB doesn't exist, as we're at featureC
data.featureB.x = data.featureA.x
}
versionC() {
// Have to make sure that featureB was actually created
data.featureC.x = data.featureB.x
} So that might be tricky
|
Having faced this as a professional game dev, a common pattern is to use a version field for the save games. Then when the save is loaded, you incrementally upgrade the save to each version. Like v2 would add a field, v3 would remove 2 fields, v4 adds a new feature. Along the way you transform the save based on the need of that version, and when you get to the end you have an up-to-date save you can pass in to the game. For example: if (save.version < 2) {
save.someField = 5
}
if (save.version < 3) {
save.anotherField = save.removedField * 5;
delete save.removedField
}
if (save.version < latestSaveVersion) {
save.version = latestSaveVersion
}
startGameWithSave(save) |
As your game grows, you will add and remove functionality. Your save files should be able to handle this and not crash when someone loads an older save
Now there are some considerations to be made. Previously loading went like this.
Now the parsing step is missing, and we directly load the data from localstorage. You can still easily do defaults with
Which is fine. We will have to
applyUpdates()
betweeninitialize()
andload()
But I'm not sure all desired functionality, like refunding upgrades can still be achieved in the current state.
Possible API
Requirements
The text was updated successfully, but these errors were encountered: