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