Skip to content

Commit

Permalink
fix: player JSON.Parse bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Cygnusfear committed Oct 20, 2023
1 parent b26d633 commit 5046233
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/client/src/game/data/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ export const initializePlayer = ({
};

export const savePlayer = async (playerData: PlayerData, verbose = false) => {
const cleanData = JSON.parse(JSON.stringify(playerData)) as PlayerData;
cleanData.facilities = [];
setItem("playerData", JSON.stringify(cleanData)).then(() => {
if (verbose) console.log("saved", cleanData);
const cleanPlayer: PlayerData = {
resources: { ...playerData.resources },
activeTutorials: [...playerData.activeTutorials],
finishedTutorials: [...playerData.finishedTutorials],
address: playerData.address,
name: playerData.name,
facilities: [],
};
setItem("playerData", JSON.stringify(cleanPlayer)).then(() => {
if (verbose) console.log("saved", cleanPlayer);
});
};

Expand Down

0 comments on commit 5046233

Please sign in to comment.