From 93ae069abaee26b53cd78969ae25dbe9240abc34 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 14 Dec 2022 09:17:11 +0100 Subject: [PATCH] save system --- assets/Scripts/AppRoot/SaveSystem.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/Scripts/AppRoot/SaveSystem.ts b/assets/Scripts/AppRoot/SaveSystem.ts index 78307a0..9a7eb31 100644 --- a/assets/Scripts/AppRoot/SaveSystem.ts +++ b/assets/Scripts/AppRoot/SaveSystem.ts @@ -2,7 +2,7 @@ import { sys } from "cc"; import { UserData } from "../Game/Data/UserData"; export class SaveSystem { - private userDataIdentifier = "user-data"; + private userDataIdentifier = "user-dat"; public save(userData: UserData): void { sys.localStorage.setItem(this.userDataIdentifier, JSON.stringify(userData)); } @@ -13,6 +13,7 @@ export class SaveSystem { if (!data) return new UserData(); try { + // TODO: the data can be corrupted if we introduce a new field in UserData return JSON.parse(data); } catch (error) { return new UserData();