rename LocalScoreManager to LocalStorageManager
This commit is contained in:
+1
-1
@@ -83,7 +83,7 @@
|
|||||||
<script src="js/html_actuator.js"></script>
|
<script src="js/html_actuator.js"></script>
|
||||||
<script src="js/grid.js"></script>
|
<script src="js/grid.js"></script>
|
||||||
<script src="js/tile.js"></script>
|
<script src="js/tile.js"></script>
|
||||||
<script src="js/local_score_manager.js"></script>
|
<script src="js/local_storage_manager.js"></script>
|
||||||
<script src="js/game_manager.js"></script>
|
<script src="js/game_manager.js"></script>
|
||||||
<script src="js/application.js"></script>
|
<script src="js/application.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// Wait till the browser is ready to render the game (avoids glitches)
|
// Wait till the browser is ready to render the game (avoids glitches)
|
||||||
window.requestAnimationFrame(function () {
|
window.requestAnimationFrame(function () {
|
||||||
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
|
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ window.fakeStorage = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function LocalScoreManager() {
|
function LocalStorageManager() {
|
||||||
this.bestScoreKey = "bestScore";
|
this.bestScoreKey = "bestScore";
|
||||||
this.gameStateKey = "gameState";
|
this.gameStateKey = "gameState";
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ function LocalScoreManager() {
|
|||||||
this.storage = supported ? window.localStorage : window.fakeStorage;
|
this.storage = supported ? window.localStorage : window.fakeStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalScoreManager.prototype.localStorageSupported = function () {
|
LocalStorageManager.prototype.localStorageSupported = function () {
|
||||||
var testKey = "test";
|
var testKey = "test";
|
||||||
var storage = window.localStorage;
|
var storage = window.localStorage;
|
||||||
|
|
||||||
@@ -39,23 +39,23 @@ LocalScoreManager.prototype.localStorageSupported = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalScoreManager.prototype.getBestScore = function () {
|
LocalStorageManager.prototype.getBestScore = function () {
|
||||||
return this.storage.getItem(this.bestScoreKey) || 0;
|
return this.storage.getItem(this.bestScoreKey) || 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalScoreManager.prototype.setBestScore = function (score) {
|
LocalStorageManager.prototype.setBestScore = function (score) {
|
||||||
this.storage.setItem(this.bestScoreKey, score);
|
this.storage.setItem(this.bestScoreKey, score);
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalScoreManager.prototype.getGameState = function () {
|
LocalStorageManager.prototype.getGameState = function () {
|
||||||
var stateJSON = this.storage.getItem(this.gameStateKey);
|
var stateJSON = this.storage.getItem(this.gameStateKey);
|
||||||
return stateJSON ? JSON.parse(stateJSON) : null;
|
return stateJSON ? JSON.parse(stateJSON) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalScoreManager.prototype.setGameState = function (gameState) {
|
LocalStorageManager.prototype.setGameState = function (gameState) {
|
||||||
this.storage.setItem(this.gameStateKey, JSON.stringify(gameState));
|
this.storage.setItem(this.gameStateKey, JSON.stringify(gameState));
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalScoreManager.prototype.clearGameState = function () {
|
LocalStorageManager.prototype.clearGameState = function () {
|
||||||
this.storage.removeItem(this.gameStateKey);
|
this.storage.removeItem(this.gameStateKey);
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user