summaryrefslogtreecommitdiff
path: root/resources/js/memory.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/memory.js')
-rw-r--r--resources/js/memory.js31
1 files changed, 25 insertions, 6 deletions
diff --git a/resources/js/memory.js b/resources/js/memory.js
index 47cde88..40be4df 100644
--- a/resources/js/memory.js
+++ b/resources/js/memory.js
@@ -9,21 +9,39 @@ const Memory = {
* @returns {string}
*/
save () {
+ const prepareSaveData = (saveData) => {
+ const prepareMonster = (monster) => {
+ if (monster.statusEffect && monster.statusEffect.slug === 'lifeleech') {
+ monster.statusEffect = null;
+ }
+
+ return monster;
+ };
+
+ for (const idx in saveData.monsters) {
+ saveData.monsters[idx] = prepareMonster(saveData.monsters[idx]);
+ }
+ for (const idx in saveData.player.monsters) {
+ saveData.player.monsters[idx] = prepareMonster(saveData.player.monsters[idx]);
+ }
+ for (const idx in saveData.opponent.monsters) {
+ saveData.opponent.monsters[idx] = prepareMonster(saveData.opponent.monsters[idx]);
+ }
+
+ return JSON.parse(JSON.stringify(saveData));
+ };
+
const saveMonster = (monsterData, monsterState) => {
monsterData.level = monsterState.level;
monsterData.hp = monsterState.hp;
- if (monsterData.statusEffect && monsterData.statusEffect.slug === 'lifeleech') {
- monsterData.statusEffect = null;
- }
-
return monsterData;
};
/**
* @type {State}
*/
- const saveData = JSON.parse(JSON.stringify(Memory.state));
+ const saveData = prepareSaveData(Object.assign({}, Memory.state));
// monsters
for (const idx in saveData.monsters) {
@@ -163,6 +181,7 @@ const Memory = {
Memory.state.areaProgress[areaSlug] = await loadArea(areaData);
}
Memory.state.currentArea = await loadArea(loadedState.currentArea);
+ Memory.state.lastVisitedTown = loadedState.lastVisitedTown;
Memory.state.turn = loadedState.turn;
Memory.state.money = loadedState.money;
@@ -179,7 +198,7 @@ const Memory = {
Memory.state.activeTechnique = await loadTechnique(loadedState.activeTechnique);
Memory.state.activeBall = await loadInventoryItem(loadedState.activeBall);
- UI.drawArea(Memory.state.currentArea);
+ UI.drawArea();
UI.drawStatus();
UI.drawOpponentMonster();
UI.drawActiveMonster();