From cf119e4bf15b9b27c0bde2677d06a231b38fbc41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Wed, 28 Aug 2019 11:30:49 +0900 Subject: [PATCH] Fix: update typing record with timer --- src/game/typing/examination/game.js | 37 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/game/typing/examination/game.js b/src/game/typing/examination/game.js index 119f47f..8601ad7 100644 --- a/src/game/typing/examination/game.js +++ b/src/game/typing/examination/game.js @@ -53,13 +53,24 @@ TypingExamination.prototype.create = function() { if(this.textTimer === null) return; - this.textTimer.text = TimeUtil.printHHMMSSFromSec(timeLeftSec); + var timeLeft = TimeUtil.printHHMMSSFromSec(timeLeftSec); + if(timeLeft !== this.textTimer.text) { + this.textTimer.text = TimeUtil.printHHMMSSFromSec(timeLeftSec); + + this.updateCorrectUnicodeLetterCount(); + this.updateTypingRecord(); + } }).bind(this) ); this.realtimeStageTimer.setTimeOverEvent( (function() { this.textTimer.text = "타임 오버"; console.log("Time over"); + + this.updateCorrectUnicodeLetterCount(); + this.updateTypingRecord(); + + // this.inputTextContent.inputEnabled = false; }).bind(this) ); @@ -507,6 +518,20 @@ TypingExamination.prototype.onKeyUp = function(event) { this.highlightTypingContent(notTrimmedInputContent, notTrimmedTypingContent); + this.updateCorrectUnicodeLetterCount(); + this.updateTypingRecord(); + + if(event.keyCode == Phaser.Keyboard.ENTER) + this.onKeyEnter(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent); + + if(event.keyCode == Phaser.Keyboard.SPACEBAR) + this.onKeyEnter(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent); +} + +TypingExamination.prototype.updateCorrectUnicodeLetterCount = function() { + var notTrimmedInputContent = this.inputTextContent.canvasInput.value(); + var notTrimmedTypingContent = this.typingExaminationContents[this.typingIndex]; + var correctLetterCount = this.getCorrectLetterCount(notTrimmedInputContent, notTrimmedTypingContent); if(correctLetterCount === this.correctLetterCountInLine + 1) { this.correctLetterCountInLine++; @@ -530,14 +555,6 @@ TypingExamination.prototype.onKeyUp = function(event) { } else { // console.log("combinationing letter for " + " (" + notTrimmedInputContent[correctLetterCount] + "), correctLetterCount : " + correctLetterCount); } - - this.updateTypingRecord(); - - if(event.keyCode == Phaser.Keyboard.ENTER) - this.onKeyEnter(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent); - - if(event.keyCode == Phaser.Keyboard.SPACEBAR) - this.onKeyEnter(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent); } TypingExamination.prototype.onKeyEnter = function(trimmedInputContent, trimmedTypingContent, notTrimmedTypingContent) { @@ -720,7 +737,7 @@ TypingExamination.prototype.setTimeTypingStart = function() { } -TypingExamination.GAME_TIME_SEC = TimeUtil.MINUTE_SEC * 5; // 5 minutes +TypingExamination.GAME_TIME_SEC = 3; //TimeUtil.MINUTE_SEC * 5; // 5 minutes TypingExamination.SPACE_INDICATOR = "␣"; // "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · "; TypingExamination.ENTER_INDICATOR = "⏎"; // "↵"; // "↵";