Fix: stop playing after time over

This commit is contained in:
2019-08-28 23:50:52 +09:00
parent cf119e4bf1
commit 2bc00ed186
2 changed files with 56 additions and 95 deletions
+16 -1
View File
@@ -189,7 +189,7 @@ StringUtil.isKoreanAlphabet = function(char) {
return false; return false;
}; };
StringUtil.getUnicodeAlphabetCount = function(text) { StringUtil.getSyllableCount = function(text) {
var count = 0; var count = 0;
var textLen = text.length var textLen = text.length
for(var i = 0; i < textLen; i++) { for(var i = 0; i < textLen; i++) {
@@ -204,6 +204,21 @@ StringUtil.getUnicodeAlphabetCount = function(text) {
return count; return count;
}; };
StringUtil.getUnicodeAlphabetCount = function(text) {
var count = 0;
var textLen = text.length
for(var i = 0; i < textLen; i++) {
var unicodeLetter = text[i];
if(StringUtil.isKoreanAlphabet(unicodeLetter))
count += 2;
else
count++;
}
// console.log(unicodeLetter + " count : " + count);
return count;
};
StringUtil.getMultibyteIndex = function(multibyteText, unicodeCharIndex) { StringUtil.getMultibyteIndex = function(multibyteText, unicodeCharIndex) {
var multibyteTextIndex = 0; var multibyteTextIndex = 0;
var index = 0; var index = 0;
+40 -94
View File
@@ -19,7 +19,7 @@ TypingExamination.prototype.create = function() {
sessionStorageManager.setRecord(0); sessionStorageManager.setRecord(0);
this.initTypingData(); this.initialize();
sessionStorageManager.setIsNewAppHighestRecord(false); sessionStorageManager.setIsNewAppHighestRecord(false);
var experienceAppTimer = new ExperienceAppTimer(); var experienceAppTimer = new ExperienceAppTimer();
@@ -64,13 +64,15 @@ TypingExamination.prototype.create = function() {
); );
this.realtimeStageTimer.setTimeOverEvent( this.realtimeStageTimer.setTimeOverEvent(
(function() { (function() {
this.isGameOver = true;
this.textTimer.text = "타임 오버"; this.textTimer.text = "타임 오버";
console.log("Time over"); console.log("Time over");
this.updateCorrectUnicodeLetterCount(); this.updateCorrectUnicodeLetterCount();
this.updateTypingRecord(); this.updateTypingRecord();
// this.inputTextContent.inputEnabled = false; this.timeOver();
}).bind(this) }).bind(this)
); );
@@ -84,6 +86,20 @@ TypingExamination.prototype.create = function() {
// this.countDown(); // this.countDown();
} }
TypingExamination.prototype.initialize = function() {
this.typingIndex = 0;
this.isGameOver = false;
this.isTyping = false;
this.correctLetterCountInLine = 0;
this.correctSyllableLetterCountInAllLines = 0;
this.typingRecordTotal = 0;
this.animalLevelID = -1;
}
TypingExamination.prototype.fontLoaded = function() { TypingExamination.prototype.fontLoaded = function() {
this.makeAnimalRecordList(); this.makeAnimalRecordList();
// this.animalRecordList.hide(); // this.animalRecordList.hide();
@@ -237,6 +253,9 @@ TypingExamination.prototype.makeTextContents = function() {
this.inputTextContent.canvasInput.placeHolder(""); this.inputTextContent.canvasInput.placeHolder("");
// inputTextContent.canvasInput._onkeydown = this.checkInputText; // inputTextContent.canvasInput._onkeydown = this.checkInputText;
this.inputTextContent.canvasInput._onkeyup = (function() { this.inputTextContent.canvasInput._onkeyup = (function() {
if(this.isGameOver)
return;
this.onKeyUp(event); this.onKeyUp(event);
// warning // warning
// : onKeyUp is called onkeyup and onkeydown // : onKeyUp is called onkeyup and onkeydown
@@ -293,12 +312,12 @@ TypingExamination.prototype.startGame = function() {
this.showTypingExaminationContents(); this.showTypingExaminationContents();
this.showPlayingWordNumber(); this.showPlayingWordNumber();
this.realtimeStageTimer.start(); // this.realtimeStageTimer.start();
} }
TypingExamination.prototype.timeOver = function() { TypingExamination.prototype.timeOver = function() {
var timeOverText = new TimeOverText(); var timeOverText = new TimeOverText();
// this.stopAndGoResult(); this.stopAndGoResult();
} }
TypingExamination.prototype.gameOver = function() { TypingExamination.prototype.gameOver = function() {
@@ -338,25 +357,6 @@ TypingExamination.prototype.goResult = function() {
} }
TypingExamination.prototype.initTypingData = function() {
this.typingIndex = 0;
this.isGameOver = false;
this.isTyping = false;
this.timeTypingStart = 0;
this.timeTypingEnd = 0;
this.typingLetterCountTotal = 0;
this.typingRecordTotal = 0;
this.correctLetterCountInLine = 0;
this.correctUnicodeLetterCountInAllLines = 0;
this.animalLevelID = -1;
}
TypingExamination.prototype.loadExaminationContent = function() { TypingExamination.prototype.loadExaminationContent = function() {
this.dbService.requestWritingInfo( this.dbService.requestWritingInfo(
sessionStorageManager.getWritingID(), sessionStorageManager.getWritingID(),
@@ -497,12 +497,9 @@ TypingExamination.prototype.resetTypingContent = function() {
} }
TypingExamination.prototype.onKeyUp = function(event) { TypingExamination.prototype.onKeyUp = function(event) {
if(this.isGameOver) if(this.isTyping === false) {
return;
if(this.isTyping == false) {
// console.log(event); // console.log(event);
this.setTimeTypingStart(); this.startTyping();
} }
//not trimmed contents //not trimmed contents
@@ -537,9 +534,9 @@ TypingExamination.prototype.updateCorrectUnicodeLetterCount = function() {
this.correctLetterCountInLine++; this.correctLetterCountInLine++;
var correctLetter = notTrimmedInputContent[this.correctLetterCountInLine - 1]; var correctLetter = notTrimmedInputContent[this.correctLetterCountInLine - 1];
var unicodeLetterCount = StringUtil.getUnicodeAlphabetCount(correctLetter); var syllableLetterCount = StringUtil.getSyllableCount(correctLetter);
this.correctUnicodeLetterCountInAllLines += unicodeLetterCount; this.correctSyllableLetterCountInAllLines += syllableLetterCount;
// console.log(this.correctUnicodeLetterCountInAllLines + " : '" + correctLetter + "'"); // console.log(this.correctSyllableLetterCountInAllLines + " : '" + correctLetter + "'");
} else if(correctLetterCount > this.correctLetterCountInLine) { } else if(correctLetterCount > this.correctLetterCountInLine) {
var count = correctLetterCount - this.correctLetterCountInLine; var count = correctLetterCount - this.correctLetterCountInLine;
// console.log("*** missed onKeyUp event - begin : " + count); // console.log("*** missed onKeyUp event - begin : " + count);
@@ -547,9 +544,9 @@ TypingExamination.prototype.updateCorrectUnicodeLetterCount = function() {
this.correctLetterCountInLine++; this.correctLetterCountInLine++;
var correctLetter = notTrimmedInputContent[this.correctLetterCountInLine - 1]; var correctLetter = notTrimmedInputContent[this.correctLetterCountInLine - 1];
var unicodeLetterCount = StringUtil.getUnicodeAlphabetCount(correctLetter); var syllableLetterCount = StringUtil.getSyllableCount(correctLetter);
this.correctUnicodeLetterCountInAllLines += unicodeLetterCount; this.correctSyllableLetterCountInAllLines += syllableLetterCount;
// console.log(this.correctUnicodeLetterCountInAllLines + " : '" + correctLetter + "'"); // console.log(this.correctSyllableLetterCountInAllLines + " : '" + correctLetter + "'");
} }
// console.log("*** missed onKeyUp event - end"); // console.log("*** missed onKeyUp event - end");
} else { } else {
@@ -567,8 +564,8 @@ TypingExamination.prototype.onKeyEnter = function(trimmedInputContent, trimmedTy
// console.log("input completed"); // console.log("input completed");
// this.calculateTypingRecord(notTrimmedTypingContent); // this.calculateTypingRecord(notTrimmedTypingContent);
this.correctUnicodeLetterCountInAllLines++; this.correctSyllableLetterCountInAllLines++;
// console.log(this.correctUnicodeLetterCountInAllLines + " : Enter"); // console.log(this.correctSyllableLetterCountInAllLines + " : Enter");
this.correctLetterCountInLine = 0; this.correctLetterCountInLine = 0;
// update this.textTypingRecord.text with this.correctLetterCountForAllLines // update this.textTypingRecord.text with this.correctLetterCountForAllLines
this.updateTypingRecord(); this.updateTypingRecord();
@@ -621,10 +618,12 @@ TypingExamination.prototype.highlightTypingContent = function(notTrimmedInputCon
} }
TypingExamination.prototype.updateTypingRecord = function() { TypingExamination.prototype.updateTypingRecord = function() {
if(this.isGameOver)
return;
this.typingRecordTotal = this.correctUnicodeLetterCountInAllLines * TimeUtil.MINUTE_SEC / this.realtimeStageTimer.getElapsedTime(); this.typingRecordTotal = this.correctSyllableLetterCountInAllLines * TimeUtil.MINUTE_SEC / this.realtimeStageTimer.getElapsedTime();
// console.log("---"); // console.log("---");
// console.log(this.correctUnicodeLetterCountInAllLines); // console.log(this.correctSyllableLetterCountInAllLines);
// console.log(this.realtimeStageTimer.getElapsedTime()); // console.log(this.realtimeStageTimer.getElapsedTime());
// console.log(typingRecord); // console.log(typingRecord);
var typingRecordInteger = Math.floor(this.typingRecordTotal); var typingRecordInteger = Math.floor(this.typingRecordTotal);
@@ -661,50 +660,6 @@ TypingExamination.prototype.getCorrectLetterCount = function(inputContent, typin
return typingContentLength; return typingContentLength;
} }
TypingExamination.prototype.calculateTypingRecord = function(typingContent) {
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
var ONE_MINUTE_MS = Phaser.Timer.SECOND * 60;
this.isTyping = false;
this.timeTypingEnd = game.time.elapsedSince(0);
// console.log('this.timeTypingEnd : ' + this.timeTypingEnd);
var elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
// console.log('elapsedTimeMS : ' + elapsedTimeMS);
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
// console.log('typingContentLength : ' + typingContentLength);
var typingRecord = typingContentLength * (ONE_MINUTE_MS / elapsedTimeMS);
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
this.typingLetterCountTotal += typingContentLength;
this.typingRecordForLines[this.typingIndex] = typingRecord;
// console.log(this.typingRecordForLines[this.typingIndex]);
var typingElapsedTimeTotal = 0;
for(var i = 0; i <= this.typingIndex; i++) {
// console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
typingElapsedTimeTotal += this.typingElapsedTime[i];
}
// this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal;
this.typingRecordTotal = this.typingLetterCountTotal * (ONE_MINUTE_MS / typingElapsedTimeTotal);
// console.log(this.typingElapsedTime);
// console.log(this.typingLetterCountTotal);
// console.log(typingElapsedTimeTotal);
// console.log(typingRecordTotal);
var typingRecordTotalInteger = Math.floor(this.typingRecordTotal);
this.averageTypingSpeedText.print(typingRecordTotalInteger);
// console.log('-------------- total --------------');
// console.log('typingLetterCountTotal : ' + this.typingLetterCountTotal);
// console.log('typingElapsedTimeTotal : ' + typingElapsedTimeTotal);
// console.log('typingRecordTotal : ' + this.typingRecordTotal);
// console.log('-----------------------------------');
var animalLevelID = Animal.animalLevelIDByRecord(typingRecordTotalInteger, Animal.TYPE_EXAM);
this.animalRecordList.activate(animalLevelID);
this.animalRecordList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
}
TypingExamination.prototype.playNextContent = function() { TypingExamination.prototype.playNextContent = function() {
this.typingIndex++; this.typingIndex++;
@@ -719,25 +674,16 @@ TypingExamination.prototype.showPlayingWordNumber = function() {
this.textTypingLine.text = this.typingContentLength - this.typingIndex + " "; this.textTypingLine.text = this.typingContentLength - this.typingIndex + " ";
} }
TypingExamination.prototype.setTimeTypingStart = function() { TypingExamination.prototype.startTyping = function() {
if(this.inputTextContent.canvasInput.value() == "") if(this.inputTextContent.canvasInput.value() == "")
return; return;
this.timeTypingStart = game.time.elapsedSince(0); this.realtimeStageTimer.start();
var timeGap = this.timeTypingStart - this.timeTypingEnd;
if(timeGap < 50)
return;
this.isTyping = true; this.isTyping = true;
// console.log('last End : ' + this.timeTypingEnd);
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
} }
TypingExamination.GAME_TIME_SEC = 3; //TimeUtil.MINUTE_SEC * 5; // 5 minutes TypingExamination.GAME_TIME_SEC = TimeUtil.MINUTE_SEC * 5; // 5 minutes
TypingExamination.SPACE_INDICATOR = "␣"; // "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · "; TypingExamination.SPACE_INDICATOR = "␣"; // "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
TypingExamination.ENTER_INDICATOR = "⏎"; // "↵"; // "↵"; TypingExamination.ENTER_INDICATOR = "⏎"; // "↵"; // "↵";