diff --git a/js/states/GameScreen.js b/js/states/GameScreen.js index db2195e..a8efed2 100644 --- a/js/states/GameScreen.js +++ b/js/states/GameScreen.js @@ -154,6 +154,7 @@ GameScreen.prototype.updateOnce = function () { if (this.board.state == Board.ENDED) { var me = this; if (promptCallback === doesNothing) { + me.saveScore(me.board.score); alertBox("Time's up\nYour score: " + me.board.score + "\nPress OK to replay", function () { me.state.start('MainMenu'); }); @@ -402,3 +403,19 @@ GameScreen.prototype.shutdown = function () { window.board = null; this.effectSprites = []; }; + +GameScreen.prototype.saveScore = function (score) { + if (this.board.debug.autoSwipe) return ; + try { + var xp = +localStorage.ShapeClear_xp; + if (!xp) xp = 0; + xp += Math.floor(score / 10); + localStorage.ShapeClear_xp = xp; + var times = +localStorage.ShapeClear_played; + if (!times) times = 0; + localStorage.ShapeClear_played = times + 1; + } + catch (x) { + ; + } +}; diff --git a/js/states/MainMenu.js b/js/states/MainMenu.js index 2338a79..07bc4f6 100644 --- a/js/states/MainMenu.js +++ b/js/states/MainMenu.js @@ -36,10 +36,19 @@ MainMenu.prototype.create = function () { this.title.anchor.set(0.5, 0.5); this.title.inputEnabled = true; this.title.events.onInputUp.add(function () { + var xp = localStorage.ShapeClear_xp || 0; + var times = localStorage.ShapeClear_played || 0; + var lv = 1; + var req; + while (lv < 50 && xp > (req = Math.floor(prank(lv+1, 40)) * 10)) { + lv++; + } alertBox( "Copyright (c) 2016~2018 Yi-Feng Chen(陳羿豐)\n" + "Licensed under MIT license\n" + - "This game uses Phaser game engine" + "This game uses Phaser game engine\n" + + "Lv. " + lv + " xp: " + xp + "/" + req + "\n" + + "You played " + times + " times" ); Debug.createSpecial ^= 1; }, this);