From 95898b7bbd187d576ed2e765094807265f7fcce4 Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Fri, 9 Aug 2019 13:13:18 -0700 Subject: [PATCH] psedocode save load and undo functions using window.localstorage --- js/main.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index d4dc162..a4936f0 100644 --- a/js/main.js +++ b/js/main.js @@ -341,6 +341,28 @@ function initHandi() { } /*----- meta functions -----*/ + +// include save function + // unpack existing gamerecords + // globalGameRecord = JSON.parse(localStorage.getItem('browser-go-saved-games')); + // append current game record to globalGameRecord - globalGameRecord.gameName = gameState + // stringify all stored gamerecords JSON.stringify(globalGameRecord) + // localStorage.clear() + // localStorage.setItem('browser-go-saved-games') + +// load function + // unpack existing gamerecords - globalGameRecord = JSON.parse(localStorage.getItem('browser-)) + // display each game record name - Object.keys(globalGameRecord).forEach( ... ) + // upon user selection initgame from gameState meta data + +// undo last move + // set up gameState var to track number of 'misclicks' + // after every move JSON.stringify(localGameRecord) + // localStorage.clear() + // localStorage.setItem() + // on undo click - load JSON.parse(localStorage.getItem()) + // reset gameState + // plus general purpose function findPointFromIdx(arr) { @@ -480,7 +502,7 @@ function clearOverlay() { } } -function checkKo(point, cap) { +function checkKo(point, cap) { // currently prevents snapback if (!point.getLiberties().length && cap.checkNeighbors().filter(stone => stone.stone === gameState.turn * -1) && point.capturing.length === 1) return true; }