2048.html
changeset 42 716508d5494c
parent 41 359719178176
child 43 8b1577211149
equal deleted inserted replaced
41:359719178176 42:716508d5494c
   396     }
   396     }
   397     ui.game.finishStep = function() {
   397     ui.game.finishStep = function() {
   398       board.putRandom(board.current);
   398       board.putRandom(board.current);
   399       ui.board.update(board.current);
   399       ui.board.update(board.current);
   400       ui.score.update(board.current);
   400       ui.score.update(board.current);
   401       localStorage.savedBoard = board.current;
   401       localStorage.savedBoard = JSON.stringify(board.current);
   402     }
   402     }
   403 
   403 
   404     ////////////////////////////////////////////////////////////////
   404     ////////////////////////////////////////////////////////////////
   405     // Actions.
   405     // Actions.
   406 
   406 
   585     }
   585     }
   586 
   586 
   587     ui.brdEngine = BoardArr2d; // TODO make user selectable
   587     ui.brdEngine = BoardArr2d; // TODO make user selectable
   588 
   588 
   589     if (localStorage.savedBoard) {
   589     if (localStorage.savedBoard) {
   590       board.current = localStorage.savedBoard;
   590       try {
   591       ui.board.update(board.current);
   591         board.current = JSON.parse(localStorage.savedBoard);
       
   592         ui.board.update(board.current);
       
   593       } catch (ex) { }
   592     } else {
   594     } else {
   593       ui.action.start();
   595       ui.action.start();
   594     }
   596     }
   595 
   597 
   596   </script>
   598   </script>