igt-vue
igt-vue copied to clipboard
Version Updates
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.
- Get saveData from localstorage
- Parse saveData in each feature, add defaults if missing data.
- load(saveData).
Now the parsing step is missing, and we directly load the data from localstorage. You can still easily do defaults with
load(data: SaveData): void {
this.money = data.money ?? this.money;
}
Which is fine. We will have to applyUpdates()
between initialize()
and load()
But I'm not sure all desired functionality, like refunding upgrades can still be achieved in the current state.
Possible API
new VersionUpdate('0.1.2'), (data, features) => {
// Refund people who bought deleted upgrade
if (data.exampleFeature.upgrades[1].level > 0) {
features.wallet.gainMoney(3000);
}
}
Requirements
- [ ] List of old savefiles with their version, run a test that loads all of these into the current version and fails on any error.
- [ ] Run a custom function per game version. This function takes in the save file and applies any changes that need to be made.