diff --git a/src/game/typing/alphabet_list/english_basic.js b/src/game/typing/alphabet_list/english_basic.js new file mode 100644 index 0000000..e39020a --- /dev/null +++ b/src/game/typing/alphabet_list/english_basic.js @@ -0,0 +1,11 @@ +var englishBasicWordList = [ + "a", + "s", + "d", + "f", + "j", + "k", + "l", + ";", + "'" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/english_left_lower.js b/src/game/typing/alphabet_list/english_left_lower.js new file mode 100644 index 0000000..2798413 --- /dev/null +++ b/src/game/typing/alphabet_list/english_left_lower.js @@ -0,0 +1,6 @@ +var englishLeftLowerWordList = [ + "z", + "x", + "c", + "v" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/english_left_upper.js b/src/game/typing/alphabet_list/english_left_upper.js new file mode 100644 index 0000000..9c13ae2 --- /dev/null +++ b/src/game/typing/alphabet_list/english_left_upper.js @@ -0,0 +1,6 @@ +var englishLeftUpperWordList = [ + "q", + "w", + "e", + "r" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/english_right_lower.js b/src/game/typing/alphabet_list/english_right_lower.js new file mode 100644 index 0000000..5844f05 --- /dev/null +++ b/src/game/typing/alphabet_list/english_right_lower.js @@ -0,0 +1,7 @@ +var englishRightLowerWordList = [ + "m", + "m", + ",", + ".", + "/" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/english_right_upper.js b/src/game/typing/alphabet_list/english_right_upper.js new file mode 100644 index 0000000..9a5f06d --- /dev/null +++ b/src/game/typing/alphabet_list/english_right_upper.js @@ -0,0 +1,9 @@ +var englishRightUpperWordList = [ + "u", + "i", + "o", + "p", + "[", + "]", + "\\" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/english_second_finger.js b/src/game/typing/alphabet_list/english_second_finger.js new file mode 100644 index 0000000..d834c4a --- /dev/null +++ b/src/game/typing/alphabet_list/english_second_finger.js @@ -0,0 +1,8 @@ +var englishSecondFingerWordList = [ + "g", + "h", + "t", + "y", + "b", + "n" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/english_sentence.js b/src/game/typing/alphabet_list/english_sentence.js new file mode 100644 index 0000000..b993b38 --- /dev/null +++ b/src/game/typing/alphabet_list/english_sentence.js @@ -0,0 +1,12 @@ +var englishSentenceList = [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +]; diff --git a/src/game/typing/alphabet_list/english_word.js b/src/game/typing/alphabet_list/english_word.js new file mode 100644 index 0000000..02f1a79 --- /dev/null +++ b/src/game/typing/alphabet_list/english_word.js @@ -0,0 +1,12 @@ +var englishWordList = [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +]; diff --git a/src/game/typing/alphabet_list/korean_basic.js b/src/game/typing/alphabet_list/korean_basic.js new file mode 100644 index 0000000..4ada84e --- /dev/null +++ b/src/game/typing/alphabet_list/korean_basic.js @@ -0,0 +1,11 @@ +var koreanBasicWordList = [ + "ㅁ", + "ㄴ", + "ㅇ", + "ㄹ", + "ㅓ", + "ㅏ", + "ㅣ", + ";", + "'" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_left_lower.js b/src/game/typing/alphabet_list/korean_left_lower.js new file mode 100644 index 0000000..b14d556 --- /dev/null +++ b/src/game/typing/alphabet_list/korean_left_lower.js @@ -0,0 +1,6 @@ +var koreanLeftLowerWordList = [ + "ㅋ", + "ㅌ", + "ㅊ", + "ㅍ" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_left_upper.js b/src/game/typing/alphabet_list/korean_left_upper.js new file mode 100644 index 0000000..6f09e3f --- /dev/null +++ b/src/game/typing/alphabet_list/korean_left_upper.js @@ -0,0 +1,6 @@ +var koreanLeftUpperWordList = [ + "ㅂ", + "ㅈ", + "ㄷ", + "ㄱ" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_left_upper_double.js b/src/game/typing/alphabet_list/korean_left_upper_double.js new file mode 100644 index 0000000..b4095f9 --- /dev/null +++ b/src/game/typing/alphabet_list/korean_left_upper_double.js @@ -0,0 +1,7 @@ +var koreanLeftUpperDoubleWordList = [ + "ㅃ", + "ㅉ", + "ㄸ", + "ㄲ", + "ㅆ" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_right_lower.js b/src/game/typing/alphabet_list/korean_right_lower.js new file mode 100644 index 0000000..19d9ba0 --- /dev/null +++ b/src/game/typing/alphabet_list/korean_right_lower.js @@ -0,0 +1,6 @@ +var koreanRightLowerWordList = [ + "ㅡ", + ",", + ".", + "/" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_right_upper.js b/src/game/typing/alphabet_list/korean_right_upper.js new file mode 100644 index 0000000..1f2fc67 --- /dev/null +++ b/src/game/typing/alphabet_list/korean_right_upper.js @@ -0,0 +1,9 @@ +var koreanRightUpperWordList = [ + "ㅕ", + "ㅑ", + "ㅐ", + "ㅔ", + "[", + "]", + "\\" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_right_upper_double.js b/src/game/typing/alphabet_list/korean_right_upper_double.js new file mode 100644 index 0000000..07faffd --- /dev/null +++ b/src/game/typing/alphabet_list/korean_right_upper_double.js @@ -0,0 +1,9 @@ +var koreanRightUpperDoubleWordList = [ + "ㅕ", + "ㅑ", + "ㅒ", + "ㅖ", + "[", + "]", + "\\" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_second_finger.js b/src/game/typing/alphabet_list/korean_second_finger.js new file mode 100644 index 0000000..15fc5d6 --- /dev/null +++ b/src/game/typing/alphabet_list/korean_second_finger.js @@ -0,0 +1,8 @@ +var koreanSecondFingerWordList = [ + "ㅎ", + "ㅗ", + "ㅅ", + "ㅛ", + "ㅠ", + "ㅜ" +]; \ No newline at end of file diff --git a/src/game/typing/alphabet_list/korean_sentence.js b/src/game/typing/alphabet_list/korean_sentence.js new file mode 100644 index 0000000..aa52bfd --- /dev/null +++ b/src/game/typing/alphabet_list/korean_sentence.js @@ -0,0 +1,12 @@ +var koreanSentenceList = [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +]; diff --git a/src/game/typing/alphabet_list/korean_word.js b/src/game/typing/alphabet_list/korean_word.js new file mode 100644 index 0000000..89a69bd --- /dev/null +++ b/src/game/typing/alphabet_list/korean_word.js @@ -0,0 +1,12 @@ +var koreanWordList = [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +]; diff --git a/src/game/typing/practice/english_key_mapper.js b/src/game/typing/practice/english_key_mapper.js deleted file mode 100644 index 42bf2fe..0000000 --- a/src/game/typing/practice/english_key_mapper.js +++ /dev/null @@ -1,36 +0,0 @@ -class EnglishKeyMapper extends KeyMapper { - - constructor() { - super(); - - this.registerKeyTextData("KeyQ", "q", "Q"); - this.registerKeyTextData("KeyW", "w", "W"); - this.registerKeyTextData("KeyE", "e", "E"); - this.registerKeyTextData("KeyR", "r", "R"); - this.registerKeyTextData("KeyT", "t", "T"); - this.registerKeyTextData("KeyY", "y", "Y"); - this.registerKeyTextData("KeyU", "u", "U"); - this.registerKeyTextData("KeyI", "i", "I"); - this.registerKeyTextData("KeyO", "o", "O"); - this.registerKeyTextData("KeyP", "p", "P"); - - this.registerKeyTextData("KeyA", "a", "A"); - this.registerKeyTextData("KeyS", "s", "S"); - this.registerKeyTextData("KeyD", "d", "D"); - this.registerKeyTextData("KeyF", "f", "F"); - this.registerKeyTextData("KeyG", "g", "G"); - this.registerKeyTextData("KeyH", "h", "H"); - this.registerKeyTextData("KeyJ", "j", "J"); - this.registerKeyTextData("KeyK", "k", "K"); - this.registerKeyTextData("KeyL", "l", "L"); - - this.registerKeyTextData("KeyZ", "z", "Z"); - this.registerKeyTextData("KeyX", "x", "X"); - this.registerKeyTextData("KeyC", "c", "C"); - this.registerKeyTextData("KeyV", "v", "V"); - this.registerKeyTextData("KeyB", "b", "B"); - this.registerKeyTextData("KeyN", "n", "N"); - this.registerKeyTextData("KeyM", "m", "M"); - } - -} \ No newline at end of file diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index 91e10d0..6ac6699 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -51,13 +51,13 @@ class TypingPractice { .addColor(textPreviewColor[0], 0); - let keyMapper = null; - if(sessionStorageManager.playingAppName.indexOf("korean") > 0) - keyMapper = new KoreanKeyMapper(); - else - keyMapper = new EnglishKeyMapper(); + this.keyMapper = new KeyMapper(); + new Keyboard(this.keyMapper); - new Keyboard(keyMapper); + game.input.keyboard.processKeyPress = () => { + self.checkTypingContents(event); + } + this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT); /* @@ -85,7 +85,7 @@ class TypingPractice { screenBottom.printBottomRightText(sessionStorageManager.playerName); - // this.startGame(); + this.startGame(); // this.countDown(); } @@ -101,26 +101,36 @@ class TypingPractice { } goResult() { + this.textTypingContent.clearColors(); + this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0); + this.textTypingContent.text = "= 연습 끝 ="; + /* sessionStorageManager.record = this.typingRecordTotal; if(sessionStorageManager.record > sessionStorageManager.bestRecord) sessionStorageManager.bestRecord = sessionStorageManager.record; location.href = '../../web/client/result.html'; + */ } initTypingData() { this.typingContents = this.getTypingPracticeContents(); + console.log(this.typingContents); let randomContents = Phaser.ArrayUtils.shuffle(this.typingContents); + console.log(randomContents); this.wordCountForStage = TypingPractice.WORD_COUNT_FOR_STAGE; if(isDebugMode()) this.wordCountForStage = 3; this.typingRandomContents = randomContents.slice(1, this.wordCountForStage + 1); // start Num, end Num (not index) + console.log(this.typingRandomContents); this.typingContentLength = this.typingContents.length; this.typingIndex = 0; + + this.isTyping = false; - this.timeTypingStart = 0; - this.timeTypingEnd = 0; + // this.timeTypingStart = 0; + // this.timeTypingEnd = 0; this.typingLetterCountTotal = 0; this.typingRecordTotal = 0; @@ -128,22 +138,48 @@ class TypingPractice { getTypingPracticeContents() { - let TypingPracticeContents = this.loadTestContent(); + let TypingPracticeContents = this.loadPracticeContent(); // console.log('playingStageData.language : ' + playingStageData.language); // console.log('playingStageData.level : ' + playingStageData.level); // console.log('TypingPracticeContents : ' + TypingPracticeContents); - this.typingRecordForLines = []; - this.typingElapsedTime = []; - for(let i = 0; i < TypingPracticeContents.length; i++) { - this.typingRecordForLines[i] = 0; - this.typingElapsedTime[i] = 0; - } + // this.typingRecordForLines = []; + // this.typingElapsedTime = []; + // for(let i = 0; i < TypingPracticeContents.length; i++) { + // this.typingRecordForLines[i] = 0; + // this.typingElapsedTime[i] = 0; + // } return TypingPracticeContents; } - loadTestContent() { + loadTemporaryContent() { + testContent = [ + "ㅃ", + "ㅂ", + "ㅈ", + "ㅉ", + "ㄸ", + "ㄷ", + "ㄱ", + "ㄲ", + "ㅅ" + ]; + // testContent = [ + // "a", + // "s", + // "d", + // "f", + // "j", + // "k", + // "l", + // ";", + // "'" + // ]; + return testContent; + } + + loadPracticeContent() { let appName = ""; if(isTypingTestStage()) appName = sessionStorageManager.playingAppName.substring(5); @@ -213,40 +249,87 @@ class TypingPractice { } showTypingPracticeContents() { - for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) { - let doneIndex = this.typingIndex - i - 1; - if(doneIndex < 0) { - this.textTypingContentsDone[i].text = ""; - this.textTypingRecordsDone[i].text = ""; - } else { - this.textTypingContentsDone[i].text = this.typingRandomContents[doneIndex]; - this.textTypingRecordsDone[i].text = Math.floor(this.typingRecordForLines[doneIndex]); - } - } + let doneIndex = this.typingIndex - 1; + if(doneIndex < 0) + this.textTypingContentsDone.text = ""; + else + this.textTypingContentsDone.text = this.typingRandomContents[doneIndex]; + // for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) { + // let doneIndex = this.typingIndex - i - 1; + // if(doneIndex < 0) { + // this.textTypingContentsDone.text = ""; + // } else { + // this.textTypingContentsDone.text = this.typingRandomContents[doneIndex]; + // } + // } - if(this.typingIndex == this.wordCountForStage) { + if(this.typingIndex === this.wordCountForStage) { this.textTypingContent.text = ""; return; } this.textTypingContent.text = this.typingRandomContents[this.typingIndex]; - for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) { - let previewIndex = this.typingIndex + i + 1; - if(previewIndex < this.typingRandomContents.length) - this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex]; - else - this.textTypingContentPreview[i].text = ""; - } + let previewIndex = this.typingIndex + 1; + if(previewIndex > this.typingRandomContents.length - 1) + this.textTypingContentPreview.text = ""; + else + this.textTypingContentPreview.text = this.typingRandomContents[previewIndex]; + // for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) { + // let previewIndex = this.typingIndex + i + 1; + // if(previewIndex < this.typingRandomContents.length) + // this.textTypingContentPreview.text = this.typingRandomContents[previewIndex]; + // else + // this.textTypingContentPreview.text = ""; + // } } + /* resetTypingContent() { this.textTypingContent.clearColors(); - this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_WRONG, 0); - this.inputTextContent.canvasInput.value(''); + this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0); + } + */ + + getKeyCode(text) { + return this.keyMapper.getKeyIDOfText(text); + } + + isKeyPressed(inputContent, typingContent) { + let inputContentKeyCode = this.getKeyCode(inputContent); + let typingContentKeyCode = this.getKeyCode(typingContent); + + if(inputContentKeyCode !== typingContentKeyCode) + return false; + + let isShiftInputContent = this.shiftKey.isDown; + let isShiftTypingContent = this.keyMapper.isShiftText(typingContent); + + if(isShiftInputContent !== isShiftTypingContent) + return false; + + return true; } checkTypingContents(evnet) { + let inputContent = event.key; + let typingContent = this.typingRandomContents[this.typingIndex]; + + // if(this.getKeyCode(inputContent) === this.getKeyCode(typingContent) + // && this.getShiftTypeOfText(inputContent) === this.getShiftTypeOfText(typingContent)) { + // console.log("correct key"); + // } + + // if(shiftKey.isDown) + // console.log(this.shiftKey); + if(this.isKeyPressed(inputContent, typingContent)) { + this.playNextContent(); + + if(this.typingIndex === this.wordCountForStage) { + this.goResult(); + } + } + /* if(event.keyCode == Phaser.Keyboard.ENTER) { // console.log("### enter ###"); let inputContent = this.inputTextContent.canvasInput.value(); @@ -270,8 +353,10 @@ class TypingPractice { this.showTypingContentHighlight(); } + */ } + /* showTypingContentHighlight() { let typingContent = this.typingRandomContents[this.typingIndex]; let inputContent = this.inputTextContent.canvasInput.value(); @@ -293,7 +378,9 @@ class TypingPractice { } } } + */ + /* calculateTypingRecord(typingContent) { // console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]); @@ -310,17 +397,17 @@ class TypingPractice { let typingRecord = (typingContentPlusEnterCount + TypingPractice.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS; - this.typingElapsedTime[this.typingIndex] = elapsedTimeMS; + // this.typingElapsedTime[this.typingIndex] = elapsedTimeMS; this.typingLetterCountTotal += typingContentPlusEnterCount; - this.typingRecordForLines[this.typingIndex] = typingRecord; + // this.typingRecordForLines[this.typingIndex] = typingRecord; // console.log(this.typingRecordForLines[this.typingIndex]); - let typingElapsedTimeTotal = 0; - for(let i = 0; i <= this.typingIndex; i++) { - // console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]); - typingElapsedTimeTotal += this.typingElapsedTime[i]; - } - this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal; + // let typingElapsedTimeTotal = 0; + // for(let i = 0; i <= this.typingIndex; i++) { + // // console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]); + // typingElapsedTimeTotal += this.typingElapsedTime[i]; + // } + // this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal; // console.log(this.typingLetterCountTotal); // console.log(typingElapsedTimeTotal); // console.log(typingRecordTotal); @@ -331,18 +418,20 @@ class TypingPractice { // console.log('typingRecordTotal : ' + typingRecordTotal); // console.log('-----------------------------------'); } + */ playNextContent() { this.typingIndex++; this.showTypingPracticeContents(); this.showPlayingWordNumber(); - this.resetTypingContent(); + // this.resetTypingContent(); } showPlayingWordNumber() { this.contentProgressText.print(this.typingIndex + 1, this.wordCountForStage); } + /* setTimeTypingStart() { this.timeTypingStart = game.time.elapsedSince(0); let timeGap = this.timeTypingStart - this.timeTypingEnd; @@ -356,6 +445,7 @@ class TypingPractice { // console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd)); } + */ } diff --git a/src/game/typing/practice/key_mapper.js b/src/game/typing/practice/key_mapper.js index 687696f..5af0309 100644 --- a/src/game/typing/practice/key_mapper.js +++ b/src/game/typing/practice/key_mapper.js @@ -13,6 +13,13 @@ class KeyMapper { this.keyboardKeyMap = {}; this.inputKeyMap = {}; + this.registerFunctionKey(); + this.registerEnglishKey(); + this.registerKoreanKey(); + } + + + registerFunctionKey() { this.registerKeyTextData("Backquote", "`", "~"); this.registerKeyTextData("Digit1", "1", "!"); this.registerKeyTextData("Digit2", "2", "@"); @@ -52,12 +59,73 @@ class KeyMapper { this.registerKeyTextData("korean_english", "한/영", "한/영"); this.registerKeyTextData("AltRight", "alt", "alt"); this.registerKeyTextData("ControlRight", "ctrl", "ctrl"); - - console.log(this.keyboardKeyMap); } - registerKeyTextData(keyID, normalText, shiftText, shiftHandSide) { - this.keyboardKeyMap[keyID] = new KeyTextData(normalText, shiftText, shiftHandSide); + registerEnglishKey() { + this.registerKeyTextData("KeyQ", "q", "Q"); + this.registerKeyTextData("KeyW", "w", "W"); + this.registerKeyTextData("KeyE", "e", "E"); + this.registerKeyTextData("KeyR", "r", "R"); + this.registerKeyTextData("KeyT", "t", "T"); + this.registerKeyTextData("KeyY", "y", "Y"); + this.registerKeyTextData("KeyU", "u", "U"); + this.registerKeyTextData("KeyI", "i", "I"); + this.registerKeyTextData("KeyO", "o", "O"); + this.registerKeyTextData("KeyP", "p", "P"); + + this.registerKeyTextData("KeyA", "a", "A"); + this.registerKeyTextData("KeyS", "s", "S"); + this.registerKeyTextData("KeyD", "d", "D"); + this.registerKeyTextData("KeyF", "f", "F"); + this.registerKeyTextData("KeyG", "g", "G"); + this.registerKeyTextData("KeyH", "h", "H"); + this.registerKeyTextData("KeyJ", "j", "J"); + this.registerKeyTextData("KeyK", "k", "K"); + this.registerKeyTextData("KeyL", "l", "L"); + + this.registerKeyTextData("KeyZ", "z", "Z"); + this.registerKeyTextData("KeyX", "x", "X"); + this.registerKeyTextData("KeyC", "c", "C"); + this.registerKeyTextData("KeyV", "v", "V"); + this.registerKeyTextData("KeyB", "b", "B"); + this.registerKeyTextData("KeyN", "n", "N"); + this.registerKeyTextData("KeyM", "m", "M"); + } + + registerKoreanKey() { + this.registerKeyTextData("KeyQ", "ㅂ", "ㅃ"); + this.registerKeyTextData("KeyW", "ㅈ", "ㅉ"); + this.registerKeyTextData("KeyE", "ㄷ", "ㄸ"); + this.registerKeyTextData("KeyR", "ㄱ", "ㄲ"); + this.registerKeyTextData("KeyT", "ㅅ", "ㅆ"); + this.registerKeyTextData("KeyY", "ㅛ", "ㅛ"); + this.registerKeyTextData("KeyU", "ㅕ", "ㅕ"); + this.registerKeyTextData("KeyI", "ㅑ", "ㅑ"); + this.registerKeyTextData("KeyO", "ㅐ", "ㅒ"); + this.registerKeyTextData("KeyP", "ㅔ", "ㅖ"); + + this.registerKeyTextData("KeyA", "ㅁ", "ㅁ"); + this.registerKeyTextData("KeyS", "ㄴ", "ㄴ"); + this.registerKeyTextData("KeyD", "ㅇ", "ㅇ"); + this.registerKeyTextData("KeyF", "ㄹ", "ㄹ"); + this.registerKeyTextData("KeyG", "ㅎ", "ㅎ"); + this.registerKeyTextData("KeyH", "ㅗ", "ㅗ"); + this.registerKeyTextData("KeyJ", "ㅓ", "ㅓ"); + this.registerKeyTextData("KeyK", "ㅏ", "ㅏ"); + this.registerKeyTextData("KeyL", "ㅣ", "ㅣ"); + + this.registerKeyTextData("KeyZ", "ㅋ", "ㅋ"); + this.registerKeyTextData("KeyX", "ㅌ", "ㅌ"); + this.registerKeyTextData("KeyC", "ㅊ", "ㅊ"); + this.registerKeyTextData("KeyV", "ㅍ", "ㅍ"); + this.registerKeyTextData("KeyB", "ㅠ", "ㅠ"); + this.registerKeyTextData("KeyN", "ㅜ", "ㅜ"); + this.registerKeyTextData("KeyM", "ㅡ", "ㅡ"); + } + + + registerKeyTextData(keyID, normalText, shiftText) { + this.keyboardKeyMap[keyID] = new KeyTextData(normalText, shiftText); if(this.inputKeyMap[keyID] === undefined) this.inputKeyMap[keyID] = keyID; @@ -84,23 +152,20 @@ class KeyMapper { return this.keyboardKeyMap[keyID].shiftText; } - getShiftHandSide(keyID) { - if(this.keyboardKeyMap[keyID] === undefined) { - console.log(keyID); - return "?"; - } - return this.keyboardKeyMap[keyID].shiftHandSide; - } - getKeyIDOfText(text) { return this.inputKeyMap[text]; } - getShiftTypeOfText(text) { + isShiftText(text) { let keyID = this.getKeyIDOfText(text); - return this.keyboardKeyMap[keyID].shiftHandSide; + let keyTextData = this.keyboardKeyMap[keyID]; + + if(keyTextData.normalText === text) + return false; + + return true; } } diff --git a/src/game/typing/practice/keyboard.js b/src/game/typing/practice/keyboard.js index dfa79b2..e2e5846 100644 --- a/src/game/typing/practice/keyboard.js +++ b/src/game/typing/practice/keyboard.js @@ -13,6 +13,9 @@ class Keyboard { this.keyUpReservations = []; game.input.keyboard.addCallbacks(this, this.keyDown, this.keyUp, null); + // game.input.keyboard.processKeyDown = this.keyDown; + // game.input.keyboard.processKeyUp = this.keyUp; + let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT); shiftKey.onDown.add(this.shifted, this); @@ -370,17 +373,17 @@ class Keyboard { } -Keyboard.DEFAULT_KEY_SIZE_PX = 46; -Keyboard.BACKSPACE_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.5; -Keyboard.TAB_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.5; -Keyboard.CAPS_LOCK_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.9; -Keyboard.ENTER_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.75; -Keyboard.SHIFT_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 2.4; -Keyboard.CTRL_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.7; -Keyboard.WINDOW_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX; -Keyboard.ALT_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.5; -Keyboard.CHINESE_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX; -Keyboard.SPACE_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 5.9; +Keyboard.DEFAULT_KEY_SIZE_PX = 46; +Keyboard.BACKSPACE_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.5; +Keyboard.TAB_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.5; +Keyboard.CAPS_LOCK_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.9; +Keyboard.ENTER_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.75; +Keyboard.SHIFT_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 2.4; +Keyboard.CTRL_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.7; +Keyboard.WINDOW_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX; +Keyboard.ALT_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.5; +Keyboard.CHINESE_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX; +Keyboard.SPACE_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 5.9; Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX; Keyboard.KEY_GAP_PX = 6; diff --git a/src/game/typing/practice/korean_key_mapper.js b/src/game/typing/practice/korean_key_mapper.js deleted file mode 100644 index efa1c01..0000000 --- a/src/game/typing/practice/korean_key_mapper.js +++ /dev/null @@ -1,36 +0,0 @@ -class KoreanKeyMapper extends KeyMapper { - - constructor() { - super(); - - this.registerKeyTextData("KeyQ", "ㅂ", "ㅃ"); - this.registerKeyTextData("KeyW", "ㅈ", "ㅉ"); - this.registerKeyTextData("KeyE", "ㄷ", "ㄸ"); - this.registerKeyTextData("KeyR", "ㄱ", "ㄲ"); - this.registerKeyTextData("KeyT", "ㅅ", "ㅆ"); - this.registerKeyTextData("KeyY", "ㅛ", "ㅛ"); - this.registerKeyTextData("KeyU", "ㅕ", "ㅕ"); - this.registerKeyTextData("KeyI", "ㅑ", "ㅑ"); - this.registerKeyTextData("KeyO", "ㅐ", "ㅒ"); - this.registerKeyTextData("KeyP", "ㅔ", "ㅖ"); - - this.registerKeyTextData("KeyA", "ㅁ", "ㅁ"); - this.registerKeyTextData("KeyS", "ㄴ", "ㄴ"); - this.registerKeyTextData("KeyD", "ㅇ", "ㅇ"); - this.registerKeyTextData("KeyF", "ㄹ", "ㄹ"); - this.registerKeyTextData("KeyG", "ㅎ", "ㅎ"); - this.registerKeyTextData("KeyH", "ㅗ", "ㅗ"); - this.registerKeyTextData("KeyJ", "ㅓ", "ㅓ"); - this.registerKeyTextData("KeyK", "ㅏ", "ㅏ"); - this.registerKeyTextData("KeyL", "ㅣ", "ㅣ"); - - this.registerKeyTextData("KeyZ", "ㅋ", "ㅋ"); - this.registerKeyTextData("KeyX", "ㅌ", "ㅌ"); - this.registerKeyTextData("KeyC", "ㅊ", "ㅊ"); - this.registerKeyTextData("KeyV", "ㅍ", "ㅍ"); - this.registerKeyTextData("KeyB", "ㅠ", "ㅠ"); - this.registerKeyTextData("KeyN", "ㅜ", "ㅜ"); - this.registerKeyTextData("KeyM", "ㅡ", "ㅡ"); - } - -} \ No newline at end of file diff --git a/src/game/typing/word_list/english_right_upper.js b/src/game/typing/word_list/english_right_upper.js index 322d000..7df9c8c 100644 --- a/src/game/typing/word_list/english_right_upper.js +++ b/src/game/typing/word_list/english_right_upper.js @@ -1,4 +1,4 @@ -var englishLeftUpperWordList = [ +var englishRightUpperWordList = [ "port", "upside", "kid", diff --git a/src/web/client/typing_practice.html b/src/web/client/typing_practice.html index e46e858..f89df3e 100644 --- a/src/web/client/typing_practice.html +++ b/src/web/client/typing_practice.html @@ -28,25 +28,25 @@ - - - - - - - - - - + + + + + + + + + + - - - - - - - - + + + + + + + +