Skip to content

Commit 08c50df

Browse files
rename LocalScoreManager to LocalStorageManager
1 parent bd7f896 commit 08c50df

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ <h1 class="title">2048</h1>
8383
<script src="js/html_actuator.js"></script>
8484
<script src="js/grid.js"></script>
8585
<script src="js/tile.js"></script>
86-
<script src="js/local_score_manager.js"></script>
86+
<script src="js/local_storage_manager.js"></script>
8787
<script src="js/game_manager.js"></script>
8888
<script src="js/application.js"></script>
8989
</body>

js/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Wait till the browser is ready to render the game (avoids glitches)
22
window.requestAnimationFrame(function () {
3-
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
3+
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
44
});

js/local_score_manager.js renamed to js/local_storage_manager.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ window.fakeStorage = {
1818
}
1919
};
2020

21-
function LocalScoreManager() {
21+
function LocalStorageManager() {
2222
this.bestScoreKey = "bestScore";
2323
this.gameStateKey = "gameState";
2424

2525
var supported = this.localStorageSupported();
2626
this.storage = supported ? window.localStorage : window.fakeStorage;
2727
}
2828

29-
LocalScoreManager.prototype.localStorageSupported = function () {
29+
LocalStorageManager.prototype.localStorageSupported = function () {
3030
var testKey = "test";
3131
var storage = window.localStorage;
3232

@@ -39,23 +39,23 @@ LocalScoreManager.prototype.localStorageSupported = function () {
3939
}
4040
};
4141

42-
LocalScoreManager.prototype.getBestScore = function () {
42+
LocalStorageManager.prototype.getBestScore = function () {
4343
return this.storage.getItem(this.bestScoreKey) || 0;
4444
};
4545

46-
LocalScoreManager.prototype.setBestScore = function (score) {
46+
LocalStorageManager.prototype.setBestScore = function (score) {
4747
this.storage.setItem(this.bestScoreKey, score);
4848
};
4949

50-
LocalScoreManager.prototype.getGameState = function () {
51-
var stateJSON = this.storage.getItem(this.gameStateKey);
52-
return stateJSON ? JSON.parse(stateJSON) : null;
50+
LocalStorageManager.prototype.getGameState = function () {
51+
var stateJSON = this.storage.getItem(this.gameStateKey);
52+
return stateJSON ? JSON.parse(stateJSON) : null;
5353
};
5454

55-
LocalScoreManager.prototype.setGameState = function (gameState) {
56-
this.storage.setItem(this.gameStateKey, JSON.stringify(gameState));
55+
LocalStorageManager.prototype.setGameState = function (gameState) {
56+
this.storage.setItem(this.gameStateKey, JSON.stringify(gameState));
5757
};
5858

59-
LocalScoreManager.prototype.clearGameState = function () {
60-
this.storage.removeItem(this.gameStateKey);
59+
LocalStorageManager.prototype.clearGameState = function () {
60+
this.storage.removeItem(this.gameStateKey);
6161
};

0 commit comments

Comments
 (0)