Fix: restructing session manager, ES6 -> ES5

This commit is contained in:
2018-09-14 22:22:22 +09:00
parent 72e7c1a28f
commit 3f340535ac
44 changed files with 3100 additions and 3262 deletions
+39 -42
View File
@@ -1,13 +1,10 @@
/////////////////////////////
// TypingTest
var TypingTest = {
class TypingTest {
create() {
create: function() {
self = this;
this.initTypingData();
sessionStorageManager.isNewBestRecrd = false;
sessionStorageManager.setIsNewBestRecord(false);
game.stage.backgroundColor = '#4d4d4d';
@@ -105,14 +102,14 @@ class TypingTest {
// bottom ui
let screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
screenBottomUI.printRightText(sessionStorageManager.playerName);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
this.startGame();
// this.countDown();
}
},
/*
countDown() {
@@ -145,30 +142,30 @@ class TypingTest {
}
*/
startGame() {
startGame: function() {
this.averageTypingSpeedText.print(0);
this.showTypingTestContents();
this.showPlayingWordNumber();
}
},
gameOver() {
gameOver: function() {
let gameOverText = new GameOverText();
this.animalOnTitle.stopAnimation();
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
}
},
goResult() {
sessionStorageManager.record = this.typingRecordTotal;
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
sessionStorageManager.bestRecord = sessionStorageManager.record;
goResult: function() {
sessionStorageManager.setRecord(this.typingRecordTotal);
if(sessionStorageManager.getRecord() > sessionStorageManager.getBestRecord())
sessionStorageManager.setBestRecord(sessionStorageManager.record);
location.href = '../../web/client/result.html';
}
},
initTypingData() {
initTypingData: function() {
let typingTextMan = new TypingTextManager();
let typingPracticeContents = this.getTypingTestContents();
@@ -190,10 +187,10 @@ class TypingTest {
this.typingLetterCountTotal = 0;
this.typingRecordTotal = 0;
}
},
getTypingTestContents() {
getTypingTestContents: function() {
let typingTestContents = this.loadTestContent();
// console.log('playingStageData.language : ' + playingStageData.language);
// console.log('playingStageData.level : ' + playingStageData.level);
@@ -207,14 +204,14 @@ class TypingTest {
}
return typingTestContents;
}
},
loadTestContent() {
loadTestContent: function() {
let appName = "";
if(isTypingTestStage())
appName = sessionStorageManager.playingAppName.substring(5);
appName = sessionStorageManager.getPlayingAppName().substring(5);
else if(isTypingPracticeStage())
appName = sessionStorageManager.playingAppName.substring(9);
appName = sessionStorageManager.getPlayingAppName().substring(9);
let testContent = [];
switch(appName) {
@@ -276,9 +273,9 @@ class TypingTest {
}
return testContent;
}
},
showTypingTestContents() {
showTypingTestContents: function() {
for(let i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
let doneIndex = this.typingIndex - i - 1;
if(doneIndex < 0) {
@@ -304,15 +301,15 @@ class TypingTest {
else
this.textTypingContentPreview[i].text = "";
}
}
},
resetTypingContent() {
resetTypingContent: function() {
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_INPUT, 0);
this.inputTextContent.canvasInput.value('');
}
},
checkTypingContents(evnet) {
checkTypingContents: function(evnet) {
if(event.keyCode == Phaser.Keyboard.ENTER) {
// console.log("### enter ###");
let inputContent = this.inputTextContent.canvasInput.value();
@@ -336,9 +333,9 @@ class TypingTest {
this.showTypingContentHighlight();
}
}
},
showTypingContentHighlight() {
showTypingContentHighlight: function() {
let typingContent = this.typingRandomContents[this.typingIndex];
let inputContent = this.inputTextContent.canvasInput.value();
@@ -358,9 +355,9 @@ class TypingTest {
return;
}
}
}
},
calculateTypingRecord(typingContent) {
calculateTypingRecord: function(typingContent) {
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
this.isTyping = false;
@@ -404,20 +401,20 @@ class TypingTest {
this.animalOnTitle.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
this.animalOnTitle.startAnimation();
}
},
playNextContent() {
playNextContent: function() {
this.typingIndex++;
this.showTypingTestContents();
this.showPlayingWordNumber();
this.resetTypingContent();
}
},
showPlayingWordNumber() {
showPlayingWordNumber: function() {
this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
}
},
setTimeTypingStart() {
setTimeTypingStart: function() {
this.timeTypingStart = game.time.elapsedSince(0);
let timeGap = this.timeTypingStart - this.timeTypingEnd;