Fix: typing record (completed)
This commit is contained in:
@@ -193,12 +193,14 @@ StringUtil.getUnicodeAlphabetCount = function(text) {
|
||||
var count = 0;
|
||||
var textLen = text.length
|
||||
for(var i = 0; i < textLen; i++) {
|
||||
if(StringUtil.isKoreanAlphabet(text[i]))
|
||||
count += StringUtil.getUnicodeKoreanAlphabetCount(text[i]);
|
||||
var unicodeLetter = text[i];
|
||||
if(StringUtil.isKoreanAlphabet(unicodeLetter))
|
||||
count += StringUtil.getUnicodeKoreanAlphabetCount(unicodeLetter);
|
||||
else
|
||||
count++;
|
||||
}
|
||||
|
||||
// console.log(unicodeLetter + " count : " + count);
|
||||
return count;
|
||||
};
|
||||
|
||||
|
||||
@@ -340,7 +340,9 @@ TypingExamination.prototype.initTypingData = function() {
|
||||
this.typingRecordTotal = 0;
|
||||
|
||||
this.correctLetterCountInLine = 0;
|
||||
this.correctLetterCountInAllLines = 0;
|
||||
this.correctUnicodeLetterCountInAllLines = 0;
|
||||
|
||||
this.animalLevelID = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -505,24 +507,30 @@ TypingExamination.prototype.onKeyUp = function(event) {
|
||||
|
||||
this.highlightTypingContent(notTrimmedInputContent, notTrimmedTypingContent);
|
||||
|
||||
// get correct letter count
|
||||
// if the count > this.correctLetterCountInLine + 1 (2 more at onece), it's abusing (reset input text)
|
||||
// if the count = this.correctLetterCountInLine + 1
|
||||
// this.correctLetterCountInLine++
|
||||
// this.correctLetterCountForAllLines++
|
||||
// update this.textTypingRecord.text with this.correctLetterCountForAllLines
|
||||
var correctLetterCount = this.getCorrectLetterCount(trimmedInputContent, trimmedTypingContent);
|
||||
if(correctLetterCount > this.correctLetterCountInLine + 1) {
|
||||
var abusingAmount = correctLetterCount - this.correctLetterCountInLine;
|
||||
console.log("abusing!!! " + abusingAmount);
|
||||
} else {
|
||||
if(correctLetterCount === this.correctLetterCountInLine + 1) {
|
||||
var correctLetterCount = this.getCorrectLetterCount(notTrimmedInputContent, notTrimmedTypingContent);
|
||||
if(correctLetterCount === this.correctLetterCountInLine + 1) {
|
||||
this.correctLetterCountInLine++;
|
||||
|
||||
var correctLetter = notTrimmedInputContent[this.correctLetterCountInLine - 1];
|
||||
var unicodeLetterCount = StringUtil.getUnicodeAlphabetCount(correctLetter);
|
||||
this.correctUnicodeLetterCountInAllLines += unicodeLetterCount;
|
||||
// console.log(this.correctUnicodeLetterCountInAllLines + " : '" + correctLetter + "'");
|
||||
} else if(correctLetterCount > this.correctLetterCountInLine) {
|
||||
var count = correctLetterCount - this.correctLetterCountInLine;
|
||||
// console.log("*** missed onKeyUp event - begin : " + count);
|
||||
for(var i = 0; i < count; i++) {
|
||||
this.correctLetterCountInLine++;
|
||||
var correctLetter = trimmedTypingContent[correctLetterCount - 1];
|
||||
|
||||
var correctLetter = notTrimmedInputContent[this.correctLetterCountInLine - 1];
|
||||
var unicodeLetterCount = StringUtil.getUnicodeAlphabetCount(correctLetter);
|
||||
this.correctLetterCountInAllLines += unicodeLetterCount;
|
||||
this.correctUnicodeLetterCountInAllLines += unicodeLetterCount;
|
||||
// console.log(this.correctUnicodeLetterCountInAllLines + " : '" + correctLetter + "'");
|
||||
}
|
||||
// console.log("*** missed onKeyUp event - end");
|
||||
} else {
|
||||
// console.log("combinationing letter for " + " (" + notTrimmedInputContent[correctLetterCount] + "), correctLetterCount : " + correctLetterCount);
|
||||
}
|
||||
|
||||
this.updateTypingRecord();
|
||||
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER)
|
||||
@@ -542,7 +550,8 @@ TypingExamination.prototype.onKeyEnter = function(trimmedInputContent, trimmedTy
|
||||
// console.log("input completed");
|
||||
// this.calculateTypingRecord(notTrimmedTypingContent);
|
||||
|
||||
this.correctLetterCountInAllLines++;
|
||||
this.correctUnicodeLetterCountInAllLines++;
|
||||
// console.log(this.correctUnicodeLetterCountInAllLines + " : Enter");
|
||||
this.correctLetterCountInLine = 0;
|
||||
// update this.textTypingRecord.text with this.correctLetterCountForAllLines
|
||||
this.updateTypingRecord();
|
||||
@@ -555,6 +564,8 @@ TypingExamination.prototype.onKeyEnter = function(trimmedInputContent, trimmedTy
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log("\n");
|
||||
// console.log("\n");
|
||||
this.playNextContent();
|
||||
return;
|
||||
}
|
||||
@@ -594,24 +605,27 @@ TypingExamination.prototype.highlightTypingContent = function(notTrimmedInputCon
|
||||
|
||||
TypingExamination.prototype.updateTypingRecord = function() {
|
||||
|
||||
this.typingRecordTotal = this.correctLetterCountInAllLines * TimeUtil.MINUTE_SEC / this.realtimeStageTimer.getElapsedTime();
|
||||
this.typingRecordTotal = this.correctUnicodeLetterCountInAllLines * TimeUtil.MINUTE_SEC / this.realtimeStageTimer.getElapsedTime();
|
||||
// console.log("---");
|
||||
// console.log(this.correctLetterCountInAllLines);
|
||||
// console.log(this.correctUnicodeLetterCountInAllLines);
|
||||
// console.log(this.realtimeStageTimer.getElapsedTime());
|
||||
// console.log(typingRecord);
|
||||
var typingRecordInteger = Math.floor(this.typingRecordTotal);
|
||||
this.averageTypingSpeedText.print(typingRecordInteger);
|
||||
|
||||
var animalLevelID = Animal.animalLevelIDByRecord(typingRecordInteger, Animal.TYPE_EXAM);
|
||||
this.animalRecordList.activate(animalLevelID);
|
||||
this.animalRecordList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
if(animalLevelID !== this.animalLevelID) {
|
||||
this.animalLevelID = animalLevelID;
|
||||
this.animalRecordList.activate(animalLevelID);
|
||||
this.animalRecordList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
TypingExamination.prototype.getCorrectLetterCount = function(trimmedInputContent, trimmedTypingContent) {
|
||||
var typingContentLength = trimmedTypingContent.length;
|
||||
TypingExamination.prototype.getCorrectLetterCount = function(inputContent, typingContent) {
|
||||
var typingContentLength = inputContent.length;
|
||||
for(var i = 0; i < typingContentLength; i++) {
|
||||
var typingChar = trimmedTypingContent.charAt(i);
|
||||
var inputChar = trimmedInputContent.charAt(i);
|
||||
var typingChar = inputContent.charAt(i);
|
||||
var inputChar = typingContent.charAt(i);
|
||||
// console.log("typingChar : " + typingChar);
|
||||
// console.log("inputChar : " + inputChar);
|
||||
|
||||
@@ -620,8 +634,8 @@ TypingExamination.prototype.getCorrectLetterCount = function(trimmedInputContent
|
||||
// return 0;
|
||||
|
||||
if(typingChar !== inputChar) {
|
||||
// console.log("trimmedInputContent.charAt(" + i + ") : " + trimmedInputContent.charCodeAt(i).toString(16) + ", " + inputChar);
|
||||
// console.log("trimmedTypingContent.charAt(" + i + ") : " + trimmedTypingContent.charCodeAt(i).toString(16) + ", " + typingChar);
|
||||
// console.log("typingContent.charAt(" + i + ") : " + typingContent.charCodeAt(i).toString(16) + ", " + inputChar);
|
||||
// console.log("inputContent.charAt(" + i + ") : " + inputContent.charCodeAt(i).toString(16) + ", " + typingChar);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user