Fix: typing record (incompleted)
This commit is contained in:
@@ -338,6 +338,9 @@ TypingExamination.prototype.initTypingData = function() {
|
||||
|
||||
this.typingLetterCountTotal = 0;
|
||||
this.typingRecordTotal = 0;
|
||||
|
||||
this.correctLetterCountInLine = 0;
|
||||
this.correctLetterCountInAllLines = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -502,6 +505,26 @@ 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) {
|
||||
this.correctLetterCountInLine++;
|
||||
var correctLetter = trimmedTypingContent[correctLetterCount - 1];
|
||||
var unicodeLetterCount = StringUtil.getUnicodeAlphabetCount(correctLetter);
|
||||
this.correctLetterCountInAllLines += unicodeLetterCount;
|
||||
}
|
||||
}
|
||||
this.updateTypingRecord();
|
||||
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER)
|
||||
this.onKeyEnter(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent);
|
||||
|
||||
@@ -517,7 +540,12 @@ TypingExamination.prototype.onKeyEnter = function(trimmedInputContent, trimmedTy
|
||||
|
||||
if(trimmedInputContent === trimmedTypingContent) {
|
||||
// console.log("input completed");
|
||||
this.calculateTypingRecord(notTrimmedTypingContent);
|
||||
// this.calculateTypingRecord(notTrimmedTypingContent);
|
||||
|
||||
this.correctLetterCountInAllLines++;
|
||||
this.correctLetterCountInLine = 0;
|
||||
// update this.textTypingRecord.text with this.correctLetterCountForAllLines
|
||||
this.updateTypingRecord();
|
||||
|
||||
// console.log("this.typingIndex : " + this.typingIndex);
|
||||
// console.log("this.trimmedTypingContentLength : " + this.trimmedTypingContentLength);
|
||||
@@ -564,6 +592,44 @@ TypingExamination.prototype.highlightTypingContent = function(notTrimmedInputCon
|
||||
}
|
||||
}
|
||||
|
||||
TypingExamination.prototype.updateTypingRecord = function() {
|
||||
|
||||
this.typingRecordTotal = this.correctLetterCountInAllLines * TimeUtil.MINUTE_SEC / this.realtimeStageTimer.getElapsedTime();
|
||||
// console.log("---");
|
||||
// console.log(this.correctLetterCountInAllLines);
|
||||
// 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);
|
||||
}
|
||||
|
||||
TypingExamination.prototype.getCorrectLetterCount = function(trimmedInputContent, trimmedTypingContent) {
|
||||
var typingContentLength = trimmedTypingContent.length;
|
||||
for(var i = 0; i < typingContentLength; i++) {
|
||||
var typingChar = trimmedTypingContent.charAt(i);
|
||||
var inputChar = trimmedInputContent.charAt(i);
|
||||
// console.log("typingChar : " + typingChar);
|
||||
// console.log("inputChar : " + inputChar);
|
||||
|
||||
// when typingChar is the last letter
|
||||
// if(isNaN(inputChar))
|
||||
// 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);
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return typingContentLength;
|
||||
}
|
||||
|
||||
TypingExamination.prototype.calculateTypingRecord = function(typingContent) {
|
||||
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
|
||||
var ONE_MINUTE_MS = Phaser.Timer.SECOND * 60;
|
||||
|
||||
Reference in New Issue
Block a user