From 6af26fb926ff619ca734ad678024e6874e757abc 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, 25 Sep 2019 09:34:15 +0900 Subject: [PATCH] Fix: show english alphabet pronounce in typing practice --- src/game/typing/practice/game.js | 50 +++++++++++++++++++++++++++++ src/web/client/typing_practice.html | 3 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index fe8d1de..720048f 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -48,6 +48,14 @@ var TypingPractice = { .addColor(TypingPractice.COLOR_CONTENT_INPUT, 0); this.textTypingContent.anchor.set(0.5); + this.pronounceText = this.makeDefaultText(game.world.centerX, TYPING_CONTENT_Y + 80); + this.pronounceText.style.fill = MainColor.LIGHT_CHOCO_STRING; + this.pronounceText.addColor(MainColor.CHOCO_STRING, 2); + this.pronounceText.setShadow(1, 1, 'rgba(0, 0, 0, 1)', 1); + // this.pronounceText.stroke = MainColor.BLACK_STRING; + // this.pronounceText.strokeThickness = 1; + + this.textTypingBracket = game.add.text(game.world.centerX, TYPING_CONTENT_Y, "[ ]", textStyleBasic) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2) .addColor(TypingPractice.COLOR_BRACKET, 0); @@ -192,6 +200,18 @@ var TypingPractice = { }, + makeDefaultText: function(x, y) { + var defaultText = game.add.text(x, y, ""); + defaultText.anchor.set(0.5, 0.5); + // defaultText.font = "Nanum Gothic Coding"; + defaultText.font = "Times New Roman"; + defaultText.fontSize = 26; + defaultText.fontWeight = "normal"; + defaultText.style.fill = "white"; + + return defaultText; + }, + loadPracticeContent: function() { var appName = ""; if(isTypingTestApp()) @@ -283,6 +303,35 @@ var TypingPractice = { return testContent; }, + isEnglishAlphabet: function(letter) { + var patternEnglishAlphabet = /[a-zA-Z]/; + if(patternEnglishAlphabet.test(letter)) + return true; + else + return false; + }, + + getPronounce: function(letter) { + var pronounceArray = [ + "에이", "비", "씨", "디", "이", "에프", "지", "에이치", "아이", + "제이", "케이", "엘", "엠", "엔", "오", "피", "큐", "알", + "에스", "티", "유", "브이", "더블유", "엑스", "와이", "지(제트)" + ]; + + var lowercaseLetter = letter.toLowerCase(); + var letterIndex = lowercaseLetter.charCodeAt(0) - "a".charCodeAt(0); + return pronounceArray[letterIndex]; + }, + + showPronounceText: function(letter) { + if(!this.isEnglishAlphabet(letter)) { + this.pronounceText.text = ""; + return; + } + + this.pronounceText.text = letter.toUpperCase() + " " + this.getPronounce(letter); + }, + showTypingPracticeContents: function() { for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) { var doneIndex = this.typingIndex - i - 1; @@ -299,6 +348,7 @@ var TypingPractice = { } this.textTypingContent.text = this.typingRandomContents[this.typingIndex]; + this.showPronounceText(this.textTypingContent.text); for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) { var previewIndex = this.typingIndex + i + 1; diff --git a/src/web/client/typing_practice.html b/src/web/client/typing_practice.html index 19e2405..f28677b 100644 --- a/src/web/client/typing_practice.html +++ b/src/web/client/typing_practice.html @@ -41,7 +41,8 @@ - + +