Skip to content

Commit

Permalink
fix(autosave): don't save until combat is completed
Browse files Browse the repository at this point in the history
 - previously this feature would save the state before the combat state was cleared, leading to console errors when the game loaded again
 - save the state after the combat is completed, and the map has changed back to the overworld.
  • Loading branch information
justindujardin committed Oct 29, 2022
1 parent bff9b10 commit 6a49c69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/models/combat/combat.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ export class CombatEffects {
this.store.dispatch(new GameStateSetKeyDataAction(data.id, true));
}

// Save game
if (localStorage.getItem('autoSave') === 'true') {
this.store.dispatch(new GameStateSaveAction());
}
return () => {
// No cleanup
};
Expand All @@ -163,6 +159,10 @@ export class CombatEffects {
switchMap(() => this.store.select(getGameMap)),
map((targetMap: string) => {
assertTrue(map, 'cannot return to invalid map from combat');
// Save game
if (localStorage.getItem('autoSave') === 'true') {
this.store.dispatch(new GameStateSaveAction());
}
return this.router.navigate(['world', targetMap]);
})
);
Expand Down

0 comments on commit 6a49c69

Please sign in to comment.