Add: typing record for each line

This commit is contained in:
2019-09-07 23:30:56 +09:00
parent f30bd7fc8b
commit bb1fa178ba
+58 -8
View File
@@ -91,6 +91,10 @@ TypingExamination.prototype.initialize = function() {
this.isGameOver = false;
this.isTyping = false;
this.isTypingLine = false;
this.timeTypingStart = 0;
this.timeTypingEnd = 0;
this.correctLetterCountInLine = 0;
this.correctSyllableLetterCountInAllLines = 0;
@@ -207,7 +211,7 @@ TypingExamination.prototype.makeTextContents = function() {
// typed done contents
this.textTypingContentsDone = [];
this.textDoneLineNumber = [];
this.textTypingRecordArray = [];
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
this.textTypingContentsDone[i] = this.makeUnderlineText(
TYPING_CONTENT_X,
@@ -216,7 +220,7 @@ TypingExamination.prototype.makeTextContents = function() {
this.textTypingContentsDone[i].style.fill = TypingExamination.COLOR_DONE_INPUT_STRING;
this.textTypingContentsDone[i].style.backgroundColor = TypingExamination.COLOR_CORRECT_INPUT_BACKGROUND_STRING;
this.textDoneLineNumber[i] = this.makeLineText(
this.textTypingRecordArray[i] = this.makeLineText(
LINE_POS_X,
TYPING_CONTENT_Y - DONE_OFFSET_Y - i * TEXT_HEIGHT,
);
@@ -436,11 +440,11 @@ TypingExamination.prototype.completeLoadingWriting = function() {
this.typingExaminationContents[this.typingExaminationContents.length - 1] += TypingExamination.ENTER_INDICATOR;
// console.log(this.typingExaminationContents);
this.typingRecordForLines = [];
this.typingRecordArray = [];
this.typingElapsedTime = [];
this.typingContentLength = this.typingExaminationContents.length;
for(var i = 0; i < this.typingContentLength; i++) {
this.typingRecordForLines[i] = 0;
this.typingRecordArray[i] = 0;
this.typingElapsedTime[i] = 0;
}
@@ -461,13 +465,16 @@ TypingExamination.prototype.showTypingExaminationContents = function() {
var doneIndex = this.typingIndex - i - 1;
if(doneIndex < 0) {
this.textTypingContentsDone[i].text = "";
this.textDoneLineNumber[i].text = "";
this.textTypingRecordArray[i].text = "";
} else {
// console.log(this.typingExaminationContents[doneIndex] + "/");
this.textTypingContentsDone[i].text = this.typingExaminationContents[doneIndex];
var lineNumber = this.typingContentLength - doneIndex;
this.textDoneLineNumber[i].text = NumberUtil.numberWithCommas(lineNumber) + " ";
// console.log(this.typingRecordArray);
var typingRecordIndex = this.typingIndex - 1 - i;
// console.log(typingRecordIndex);
var typingRecord = this.typingRecordArray[typingRecordIndex];
this.textTypingRecordArray[i].text = NumberUtil.getRecordText(typingRecord);
}
}
@@ -506,6 +513,11 @@ TypingExamination.prototype.onKeyUp = function(event) {
this.startTyping();
}
if(this.isTypingLine === false) {
// console.log(event);
this.setTimeTypingStart();
}
//not trimmed contents
var notTrimmedInputContent = this.inputTextContent.canvasInput.value();
var notTrimmedTypingContent = this.typingExaminationContents[this.typingIndex];
@@ -529,6 +541,44 @@ TypingExamination.prototype.onKeyUp = function(event) {
this.onKeyEnter(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent);
}
TypingExamination.prototype.setTimeTypingStart = function() {
if(this.inputTextContent.canvasInput.value() == "")
return;
this.isTypingLine = true;
this.timeTypingStart = game.time.elapsedSince(0);
var timeGap = this.timeTypingStart - this.timeTypingEnd;
if(timeGap < 50) {
console.log("enter input check error");
return;
}
}
TypingExamination.prototype.calculateTypingRecord = function(typingContent) {
this.isTypingLine = false;
this.timeTypingEnd = game.time.elapsedSince(0);
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
// 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 typingContentPlusEnterCount = typingContentLength + TypingExamination.TYPING_COUNT_PLUS_ENTER;
// var typingRecord = (typingContentPlusEnterCount + TypingExamination.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
var typingRecord = typingContentPlusEnterCount * TimeUtil.MINUTE_MS / elapsedTimeMS;
// this.typingRecordTotal = this.correctSyllableLetterCountInAllLines * TimeUtil.MINUTE_SEC / this.realtimeStageTimer.getElapsedTime();
// this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
// this.typingLetterCountTotal += typingContentPlusEnterCount;
this.typingRecordArray[this.typingIndex] = typingRecord;
}
TypingExamination.prototype.updateCorrectUnicodeLetterCount = function() {
var notTrimmedInputContent = this.inputTextContent.canvasInput.value();
var notTrimmedTypingContent = this.typingExaminationContents[this.typingIndex];
@@ -566,7 +616,7 @@ TypingExamination.prototype.onKeyEnter = function(trimmedInputContent, trimmedTy
if(trimmedInputContent === trimmedTypingContent) {
// console.log("input completed");
// this.calculateTypingRecord(notTrimmedTypingContent);
this.calculateTypingRecord(notTrimmedTypingContent);
this.correctSyllableLetterCountInAllLines++;
// console.log(this.correctSyllableLetterCountInAllLines + " : Enter");