From 7907ae34cf595b18112d105107f31844d35578e5 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: Tue, 12 Jun 2018 17:43:34 +0900 Subject: [PATCH] Add: KeyMapper --- .../typing/practice/english_key_mapper.js | 36 ++ src/game/typing/practice/game.js | 18 +- src/game/typing/practice/key_button.js | 56 +- src/game/typing/practice/key_mapper.js | 108 ++++ src/game/typing/practice/keyboard.js | 531 +++++++++--------- src/game/typing/practice/korean_key_mapper.js | 36 ++ src/web/client/typing_practice.html | 3 + ...pp_info_manager.js => app_info_manager.js} | 0 ...nnect_manager.js => db_connect_manager.js} | 0 ...test_heart_manager.js => heart_manager.js} | 0 ...d_manager.js => history_record_manager.js} | 0 test/key_mapper.html | 28 + test/key_mapper.js | 69 +++ test/{test_number_util.js => number_util.js} | 0 ...d_manager.js => ranking_record_manager.js} | 0 ...test_score_manager.js => score_manager.js} | 0 ..._manager.js => session_storage_manager.js} | 0 test/{tests.js => tdd.js} | 0 18 files changed, 603 insertions(+), 282 deletions(-) create mode 100644 src/game/typing/practice/english_key_mapper.js create mode 100644 src/game/typing/practice/key_mapper.js create mode 100644 src/game/typing/practice/korean_key_mapper.js rename test/{test_app_info_manager.js => app_info_manager.js} (100%) rename test/{test_db_connect_manager.js => db_connect_manager.js} (100%) rename test/{test_heart_manager.js => heart_manager.js} (100%) rename test/{test_history_record_manager.js => history_record_manager.js} (100%) create mode 100644 test/key_mapper.html create mode 100644 test/key_mapper.js rename test/{test_number_util.js => number_util.js} (100%) rename test/{test_ranking_record_manager.js => ranking_record_manager.js} (100%) rename test/{test_score_manager.js => score_manager.js} (100%) rename test/{test_session_storage_manager.js => session_storage_manager.js} (100%) rename test/{tests.js => tdd.js} (100%) diff --git a/src/game/typing/practice/english_key_mapper.js b/src/game/typing/practice/english_key_mapper.js new file mode 100644 index 0000000..efbc1ce --- /dev/null +++ b/src/game/typing/practice/english_key_mapper.js @@ -0,0 +1,36 @@ +class EnglishKeyMapper extends KeyMapper { + + constructor() { + super(); + + this.registerKeyTextData("q", "q", "Q", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("w", "w", "W", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("e", "e", "E", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("r", "r", "R", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("t", "t", "T", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("y", "y", "Y", KeyTextData.LEFT_HAND); + this.registerKeyTextData("u", "u", "U", KeyTextData.LEFT_HAND); + this.registerKeyTextData("i", "i", "I", KeyTextData.LEFT_HAND); + this.registerKeyTextData("o", "o", "O", KeyTextData.LEFT_HAND); + this.registerKeyTextData("p", "p", "P", KeyTextData.LEFT_HAND); + + this.registerKeyTextData("a", "a", "A", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("s", "s", "S", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("d", "d", "D", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("f", "f", "F", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("g", "g", "G", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("h", "h", "H", KeyTextData.LEFT_HAND); + this.registerKeyTextData("j", "j", "J", KeyTextData.LEFT_HAND); + this.registerKeyTextData("k", "k", "K", KeyTextData.LEFT_HAND); + this.registerKeyTextData("l", "l", "L", KeyTextData.LEFT_HAND); + + this.registerKeyTextData("z", "z", "Z", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("x", "x", "X", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("c", "c", "C", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("v", "v", "V", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("b", "b", "B", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("n", "n", "N", KeyTextData.LEFT_HAND); + this.registerKeyTextData("m", "m", "M", KeyTextData.LEFT_HAND); + } + +} \ No newline at end of file diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index f1ed06d..d0a86b3 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -51,16 +51,22 @@ class TypingPractice { .addColor(textPreviewColor[0], 0); + let keyMapper = null; + if(sessionStorageManager.playingAppName.substring("korean") > 0) + keyMapper = new KoreanKeyMapper(); + else + keyMapper = new EnglishKeyMapper(); + // let keyButton = new KeyButton(100, 400, 100, "A", "align_type"); - new Keyboard(); + new Keyboard(keyMapper); - - this.hand_left = game.add.image(360, 680, "hand_left"); +/* + this.hand_left = game.add.image(370, 680, "hand_left"); this.hand_left.scale.set(2); this.hand_left.anchor.set(0.5); - this.hand_right = game.add.image(660, 680, "hand_right"); + this.hand_right = game.add.image(630, 680, "hand_right"); this.hand_right.scale.set(2); this.hand_right.anchor.set(0.5); @@ -69,6 +75,8 @@ class TypingPractice { mask.drawRect(100, 300, 1028, 400); this.hand_left.mask = mask; this.hand_right.mask = mask; +*/ + // bottom let screenBottom = new ScreenBottom(); @@ -78,7 +86,7 @@ class TypingPractice { screenBottom.printBottomRightText(sessionStorageManager.playerName); - game.input.keyboard.addCallbacks(this, null, null, this.keyPress); + // game.input.keyboard.addCallbacks(this, null, null, this.keyPress); // this.startGame(); // this.countDown(); } diff --git a/src/game/typing/practice/key_button.js b/src/game/typing/practice/key_button.js index 4fa9b11..93c1e01 100644 --- a/src/game/typing/practice/key_button.js +++ b/src/game/typing/practice/key_button.js @@ -1,8 +1,9 @@ class KeyButton { - constructor(x, y, width, height, normalText, shiftText, align_type) { + constructor(x, y, width, height, normalText, shiftText, alignType) { this.normalText = normalText; this.shiftText = shiftText; + this.alignType = alignType; this.setting = new RoundRectButtonSetting(x, y, width, height, KeyButton.DEFALUT_ROUND_AMOUNT_PX); this.setting.strokeWidthPx = 2; @@ -10,9 +11,9 @@ class KeyButton { this.button = this.makeButtonSprite(this.setting); this.button.inputEnabled = true; - this.text = this.makeText(this.setting, this.normalText); + this.buttonText = this.makeText(this.setting, this.normalText); if(this.normalText.length > 0) { - this.button.addChild(this.text); + this.button.addChild(this.buttonText); } } @@ -30,22 +31,51 @@ class KeyButton { } makeText(setting, textContent) { - let width = setting.width - setting.strokeWidthPx * 2; + let offsetX_px = 4; + let offsetY_px = 5; + + let width = setting.width - setting.strokeWidthPx * 2 - offsetX_px; let height = setting.height - setting.strokeWidthPx * 2; - setting.fontStyle.font = "20px Arial"; - let btnText = game.add.text(0, 0, textContent, setting.fontStyle) + if(this.alignType === KeyButton.NORMAL_KEY) + setting.fontStyle.font = "20px Courier New"; + else + setting.fontStyle.font = "11px Courier New"; + + let btnText = game.add.text(offsetX_px, offsetY_px, textContent, setting.fontStyle) .setTextBounds(setting.strokeWidthPx, setting.strokeWidthPx, width, height); - // btnText.boundsAlignH = "right"; - // btnText.boundsAlignV = "bottom"; + if(this.alignType === KeyButton.NORMAL_KEY) { + btnText.boundsAlignH = "center"; + btnText.boundsAlignV = "middle"; + } else if(this.alignType === KeyButton.LEFT_FUNCTION_KEY) { + btnText.boundsAlignH = "left"; + btnText.boundsAlignV = "bottom"; + } else if(this.alignType === KeyButton.CENTER_FUNCTION_KEY) { + btnText.boundsAlignH = "center"; + btnText.boundsAlignV = "bottom"; + } else if(this.alignType === KeyButton.RIGHT_FUNCTION_KEY) { + btnText.boundsAlignH = "right"; + btnText.boundsAlignV = "bottom"; + } - btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX; + // btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX; + + btnText.text = textContent; return btnText; } + + onShiftPressed() { + this.buttonText.text = this.shiftText; + } + + onShiftUnpressed() { + this.buttonText.text = this.normalText; + } + mouseOut() { this.text.fill = this.setting.textColors.out; this.buttonStroke.tint = this.setting.strokeColors.out; @@ -87,4 +117,10 @@ class KeyButton { KeyButton.NONE_ICON = ""; KeyButton.NONE_BUTTON_TEXT = ""; -KeyButton.DEFALUT_ROUND_AMOUNT_PX = 10; \ No newline at end of file +KeyButton.DEFALUT_ROUND_AMOUNT_PX = 10; + +KeyButton.NORMAL_KEY = "normal_key"; +KeyButton.NORMAL_FUNCTION_KEY = "normal_function_key"; +KeyButton.LEFT_FUNCTION_KEY = "left_function_key"; +KeyButton.CENTER_FUNCTION_KEY = "center_function_key"; +KeyButton.RIGHT_FUNCTION_KEY = "right_function_key"; \ No newline at end of file diff --git a/src/game/typing/practice/key_mapper.js b/src/game/typing/practice/key_mapper.js new file mode 100644 index 0000000..7c6b756 --- /dev/null +++ b/src/game/typing/practice/key_mapper.js @@ -0,0 +1,108 @@ +class KeyTextData { + + constructor(normalText, shiftText, shiftHandSide) { + this.normalText = normalText; + this.shiftText = shiftText; + this.shiftHandSide = shiftHandSide; + } + +} + +KeyTextData.HAND_LEFT = 0; +KeyTextData.HAND_RIGHT = 1; + +KeyTextData.THUMB = 0; +KeyTextData.INDEX_FINGER = 1; +KeyTextData.MIDDLE_FINGER = 2; +KeyTextData.RING_FINGER = 3; +KeyTextData.LITTLE_FINGER = 4; + +KeyTextData.LEFT_HAND = 0; +KeyTextData.RIGHT_HAND = 1; +KeyTextData.BOTH_HAND = 2; +KeyTextData.NONE_HAND = 3; + + + +class KeyMapper { + + constructor() { + this.keyboardKeyMap = {}; + this.inputKeyMap = {}; + + this.registerKeyTextData("`", "`", "~", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("1", "1", "!", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("2", "2", "@", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("3", "3", "#", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("4", "4", "$", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("5", "5", "%", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("6", "6", "^", KeyTextData.LEFT_HAND); + this.registerKeyTextData("7", "7", "&", KeyTextData.LEFT_HAND); + this.registerKeyTextData("8", "8", "*", KeyTextData.LEFT_HAND); + this.registerKeyTextData("9", "9", "(", KeyTextData.LEFT_HAND); + this.registerKeyTextData("0", "0", ")", KeyTextData.LEFT_HAND); + this.registerKeyTextData("-", "-", "_", KeyTextData.LEFT_HAND); + this.registerKeyTextData("=", "=", "+", KeyTextData.LEFT_HAND); + this.registerKeyTextData("backspace", "backspace", "backspace", KeyTextData.NONE_HAND); + + this.registerKeyTextData("tab", "tab", "tab", KeyTextData.NONE_HAND); + this.registerKeyTextData("[", "[", "{", KeyTextData.LEFT_HAND); + this.registerKeyTextData("]", "]", "}", KeyTextData.LEFT_HAND); + this.registerKeyTextData("\\", "\\", "|", KeyTextData.LEFT_HAND); + + this.registerKeyTextData("caps_lock", "caps lock", "caps lock", KeyTextData.NONE_HAND); + this.registerKeyTextData(";", ";", ":", KeyTextData.LEFT_HAND); + this.registerKeyTextData("'", "'", "\"", KeyTextData.LEFT_HAND); + this.registerKeyTextData("enter", "enter", "enter", KeyTextData.NONE_HAND); + + this.registerKeyTextData("left_shift", "left_shift", "left_shift", KeyTextData.LEFT_HAND); + this.registerKeyTextData("right_shift", "right_shift", "right_shift", KeyTextData.RIGHT_HAND); + this.registerKeyTextData(",", ",", "<", KeyTextData.LEFT_HAND); + this.registerKeyTextData(".", ".", ">", KeyTextData.LEFT_HAND); + this.registerKeyTextData("/", "/", "?", KeyTextData.LEFT_HAND); + + this.registerKeyTextData("left_ctrl", "ctrl", "ctrl", KeyTextData.NONE_HAND); + this.registerKeyTextData("window", "window", "window", KeyTextData.NONE_HAND); + this.registerKeyTextData("left_alt", "alt", "alt", KeyTextData.NONE_HAND); + this.registerKeyTextData("chinese", "한자", "한자", KeyTextData.NONE_HAND); + this.registerKeyTextData("space", "space", "space", KeyTextData.BOTH_HAND); + this.registerKeyTextData("korean_english", "한/영", "한/영", KeyTextData.NONE_HAND); + this.registerKeyTextData("right_alt", "alt", "alt", KeyTextData.NONE_HAND); + this.registerKeyTextData("right_ctrl", "ctrl", "ctrl", KeyTextData.NONE_HAND); + } + + registerKeyTextData(keyID, normalText, shiftText, shiftHandSide) { + this.keyboardKeyMap[keyID] = new KeyTextData(normalText, shiftText, shiftHandSide); + + if(this.inputKeyMap[normalText] === undefined) + this.inputKeyMap[normalText] = keyID; + if(this.inputKeyMap[shiftText] === undefined) + this.inputKeyMap[shiftText] = keyID; + } + + + getNormalText(keyID) { + // console.log(this.keyboardKeyMap[keyID]); + return this.keyboardKeyMap[keyID].normalText; + } + + getShiftText(keyID) { + return this.keyboardKeyMap[keyID].shiftText; + } + + getShiftHandSide(keyID) { + return this.keyboardKeyMap[keyID].shiftHandSide; + } + + + + getKeyIDOfText(text) { + return this.inputKeyMap[text]; + } + + getShiftTypeOfText(text) { + let keyID = this.getKeyIDOfText(text); + return this.keyboardKeyMap[keyID].shiftHandSide; + } + +} diff --git a/src/game/typing/practice/keyboard.js b/src/game/typing/practice/keyboard.js index 029637a..2b251d8 100644 --- a/src/game/typing/practice/keyboard.js +++ b/src/game/typing/practice/keyboard.js @@ -1,271 +1,54 @@ class Keyboard { - constructor() { - + constructor(keyMapper) { // let keyButton = new KeyButton(100, 400, 100, "A", "align_type"); - let keyData = this.getKeyBoardData(); + // let keyData = this.getKeyBoardData(keyMapper); - for(let i = 0; i < keyData.length; i++) { - new KeyButton( - keyData[i].x, - keyData[i].y, - keyData[i].width, - keyData[i].height, - keyData[i].normalText, - keyData[i].shiftText, - keyData[i].alignType, + this.keyIndex = 0; + this.keyDataList = []; + this.keyList = []; + this.keyHash = {}; + + let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT); + shiftKey.onDown.add(this.shifted, this); + shiftKey.onUp.add(this.unshifted, this); + + this.initKeyData(keyMapper); + + for(let i = 0; i < this.keyDataList.length; i++) { + this.keyList[i] = new KeyButton( + this.keyDataList[i].x, + this.keyDataList[i].y, + this.keyDataList[i].width, + this.keyDataList[i].height, + this.keyDataList[i].normalText, + this.keyDataList[i].shiftText, + this.keyDataList[i].alignType, ); } } - getKeyBoardData() { - let keyList = []; - let keyIndex = 0; - - - // row 1 - keyList[keyIndex] = this.makeKeyDataObject( - "`", "~", - Keyboard.KEYBOARD_OFFSET__POX_X, - Keyboard.ROW_1_POX_Y, - Keyboard.DEFAULT_KEY_SIZE_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "1", "!"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "2", "@"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "3", "#"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "4", "$"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "5", "%"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "6", "^"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "7", "&"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "8", "*"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "9", "("); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "0", ")"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "-", "_"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "=", "+"); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "backspace", "backspace", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.TAB_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - - - // row 2 - keyList[keyIndex] = this.makeKeyDataObject( - "tab", "tab", - Keyboard.KEYBOARD_OFFSET__POX_X, - Keyboard.ROW_2_POX_Y, - Keyboard.TAB_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "rightFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "q", "Q"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "w", "W"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "e", "E"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "r", "R"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "t", "T"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "y", "Y"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "u", "U"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "i", "I"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "o", "O"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "p", "P"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "[", "{"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "]", "}"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "\\", "|"); - keyIndex++; - - - // row 3 - keyList[keyIndex] = this.makeKeyDataObject( - "caps lock", "caps lock", - Keyboard.KEYBOARD_OFFSET__POX_X, - Keyboard.ROW_3_POX_Y, - Keyboard.CAPS_LOCK_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "a", "A"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "s", "S"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "d", "D"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "f", "F"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "g", "G"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "h", "H"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "j", "J"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "k", "K"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "l", "L"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], ";", ":"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "'", "\""); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "enter", "enter", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.ENTER_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "rightFunctionKey" - ); - keyIndex++; - - - // row 4 - keyList[keyIndex] = this.makeKeyDataObject( - "shift", "shift", - Keyboard.KEYBOARD_OFFSET__POX_X, - Keyboard.ROW_4_POX_Y, - Keyboard.SHIFT_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "z", "Z"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "x", "X"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "c", "C"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "v", "V"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "b", "B"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "n", "N"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "m", "M"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], ",", "<"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], ".", ">"); - keyIndex++; - keyList[keyIndex] = this.makeNextNormalKeyDataObject(keyList[keyIndex - 1], "/", "?"); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "shift", "shift", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.SHIFT_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - - // row 5 - keyList[keyIndex] = this.makeKeyDataObject( - "ctrl", "ctrl", - Keyboard.KEYBOARD_OFFSET__POX_X, - Keyboard.ROW_5_POX_Y, - Keyboard.CTRL_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "window", "window", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.WINDOW_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "alt", "alt", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.ALT_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "한자", "한자", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.CHINESE_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "space", "space", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.SPACE_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "한/영", "한/영", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "alt", "alt", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.ALT_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - keyList[keyIndex] = this.makeKeyDataObject( - "ctrl", "ctrl", - keyList[keyIndex - 1].x + keyList[keyIndex - 1].width + Keyboard.KEY_GAP_PX, - keyList[keyIndex - 1].y, - Keyboard.CTRL_KEY_WIDTH_PX, - Keyboard.DEFAULT_KEY_SIZE_PX, - "leftFunctionKey" - ); - keyIndex++; - - return keyList; + shifted() { + for(let i = 0; i < this.keyDataList.length; i++) { + this.keyList[i].onShiftPressed(); + } } + unshifted() { + for(let i = 0; i < this.keyDataList.length; i++) { + this.keyList[i].onShiftUnpressed(); + } + } + + + keyPress(char) { + // self.checkTypingContents(event); + console.log(char); + if(game.input.keyboard.isDown(Phaser.Keyboard.SHIFT)) + console.log("shift is pressed"); + } + + makeKeyDataObject(normalText, shiftText, x, y, width, height, alignType) { let keyDataObject = {}; keyDataObject.normalText = normalText; @@ -287,29 +70,243 @@ class Keyboard { prevKeyData.y, Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX, - "normalKey" + KeyButton.NORMAL_KEY ); } - addKey(normalText, shiftText, x, y, width, alignType) { - return { - normalText: normalText, shiftText: shiftText, x: x, y: y, width: width, alignType: alignType - }; + + addFunctionKeyData(keyMapper, keyID, x, y, width, height, type) { + let normalText = keyMapper.getNormalText(keyID); + let shiftText = keyMapper.getShiftText(keyID); + + let newKey = this.makeKeyDataObject(normalText, shiftText, x, y, width, height, type); + this.keyDataList[this.keyIndex] = newKey; + this.keyIndex++; + + this.keyHash[keyID] = newKey; + } + + addNextFunctionKeyData(keyMapper, keyID, width, height, type) { + let prevKey = this.keyDataList[this.keyIndex - 1]; + let normalText = keyMapper.getNormalText(keyID); + let shiftText = keyMapper.getShiftText(keyID); + + let newKey = this.makeKeyDataObject( + normalText, + shiftText, + prevKey.x + prevKey.width + Keyboard.KEY_GAP_PX, + prevKey.y, + width, + height, + type + ); + this.keyDataList[this.keyIndex] = newKey; + this.keyIndex++; + + this.keyHash[keyID] = newKey; + } + + addNextNormalKeyData(keyMapper, keyID) { + let prevKey = this.keyDataList[this.keyIndex - 1]; + let normalText = keyMapper.getNormalText(keyID); + let shiftText = keyMapper.getShiftText(keyID); + + let newKey = this.makeNextNormalKeyDataObject(prevKey, normalText, shiftText); + this.keyDataList[this.keyIndex] = newKey; + this.keyIndex++; + + this.keyHash[keyID] = newKey; + } + + + + initKeyData(keyMapper) { + // row 1 + this.addFunctionKeyData( + keyMapper, + "`", + Keyboard.KEYBOARD_OFFSET__POX_X, + Keyboard.ROW_1_POX_Y, + Keyboard.DEFAULT_KEY_SIZE_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.NORMAL_FUNCTION_KEY + ); + this.addNextNormalKeyData(keyMapper, "1"); + this.addNextNormalKeyData(keyMapper, "2"); + this.addNextNormalKeyData(keyMapper, "3"); + this.addNextNormalKeyData(keyMapper, "4"); + this.addNextNormalKeyData(keyMapper, "5"); + this.addNextNormalKeyData(keyMapper, "6"); + this.addNextNormalKeyData(keyMapper, "7"); + this.addNextNormalKeyData(keyMapper, "8"); + this.addNextNormalKeyData(keyMapper, "9"); + this.addNextNormalKeyData(keyMapper, "0"); + this.addNextNormalKeyData(keyMapper, "-"); + this.addNextNormalKeyData(keyMapper, "="); + this.addNextFunctionKeyData( + keyMapper, + "backspace", + Keyboard.BACKSPACE_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.RIGHT_FUNCTION_KEY + ); + + // row 2 + this.addFunctionKeyData( + keyMapper, + "tab", + Keyboard.KEYBOARD_OFFSET__POX_X, + Keyboard.ROW_2_POX_Y, + Keyboard.TAB_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextNormalKeyData(keyMapper, "q"); + this.addNextNormalKeyData(keyMapper, "w"); + this.addNextNormalKeyData(keyMapper, "e"); + this.addNextNormalKeyData(keyMapper, "r"); + this.addNextNormalKeyData(keyMapper, "t"); + this.addNextNormalKeyData(keyMapper, "y"); + this.addNextNormalKeyData(keyMapper, "u"); + this.addNextNormalKeyData(keyMapper, "i"); + this.addNextNormalKeyData(keyMapper, "o"); + this.addNextNormalKeyData(keyMapper, "p"); + this.addNextNormalKeyData(keyMapper, "["); + this.addNextNormalKeyData(keyMapper, "]"); + this.addNextNormalKeyData(keyMapper, "\\"); + + // row 3 + this.addFunctionKeyData( + keyMapper, + "caps_lock", + Keyboard.KEYBOARD_OFFSET__POX_X, + Keyboard.ROW_3_POX_Y, + Keyboard.CAPS_LOCK_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextNormalKeyData(keyMapper, "a"); + this.addNextNormalKeyData(keyMapper, "s"); + this.addNextNormalKeyData(keyMapper, "d"); + this.addNextNormalKeyData(keyMapper, "f"); + this.addNextNormalKeyData(keyMapper, "g"); + this.addNextNormalKeyData(keyMapper, "h"); + this.addNextNormalKeyData(keyMapper, "j"); + this.addNextNormalKeyData(keyMapper, "k"); + this.addNextNormalKeyData(keyMapper, "l"); + this.addNextNormalKeyData(keyMapper, ";"); + this.addNextNormalKeyData(keyMapper, "'"); + this.addNextFunctionKeyData( + keyMapper, + "enter", + Keyboard.ENTER_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.RIGHT_FUNCTION_KEY + ); + + // row 4 + this.addFunctionKeyData( + keyMapper, + "left_shift", + Keyboard.KEYBOARD_OFFSET__POX_X, + Keyboard.ROW_4_POX_Y, + Keyboard.SHIFT_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextNormalKeyData(keyMapper, "z"); + this.addNextNormalKeyData(keyMapper, "x"); + this.addNextNormalKeyData(keyMapper, "c"); + this.addNextNormalKeyData(keyMapper, "v"); + this.addNextNormalKeyData(keyMapper, "b"); + this.addNextNormalKeyData(keyMapper, "n"); + this.addNextNormalKeyData(keyMapper, "m"); + this.addNextNormalKeyData(keyMapper, ","); + this.addNextNormalKeyData(keyMapper, "."); + this.addNextNormalKeyData(keyMapper, "/"); + this.addNextFunctionKeyData( + keyMapper, + "right_shift", + Keyboard.SHIFT_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.RIGHT_FUNCTION_KEY + ); + + // row 5 + this.addFunctionKeyData( + keyMapper, + "left_ctrl", + Keyboard.KEYBOARD_OFFSET__POX_X, + Keyboard.ROW_5_POX_Y, + Keyboard.CTRL_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "window", + Keyboard.WINDOW_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "left_alt", + Keyboard.ALT_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "chinese", + Keyboard.CHINESE_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.LEFT_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "space", + Keyboard.SPACE_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.CENTER_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "korean_english", + Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.RIGHT_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "right_alt", + Keyboard.ALT_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.RIGHT_FUNCTION_KEY + ); + this.addNextFunctionKeyData( + keyMapper, + "right_ctrl", + Keyboard.CTRL_KEY_WIDTH_PX, + Keyboard.DEFAULT_KEY_SIZE_PX, + KeyButton.RIGHT_FUNCTION_KEY + ); } } 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.7; -Keyboard.ENTER_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 1.9; -Keyboard.SHIFT_KEY_WIDTH_PX = Keyboard.DEFAULT_KEY_SIZE_PX * 2.36; +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.84; +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 new file mode 100644 index 0000000..7e92bf1 --- /dev/null +++ b/src/game/typing/practice/korean_key_mapper.js @@ -0,0 +1,36 @@ +class KoreanKeyMapper extends KeyMapper { + + constructor() { + super(); + + this.registerKeyTextData("q", "ㅂ", "ㅃ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("w", "ㅈ", "ㅉ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("e", "ㄷ", "ㄸ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("r", "ㄱ", "ㄲ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("t", "ㅅ", "ㅆ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("y", "ㅛ", "ㅛ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("u", "ㅕ", "ㅕ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("i", "ㅑ", "ㅑ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("o", "ㅐ", "ㅒ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("p", "ㅔ", "ㅖ", KeyTextData.LEFT_HAND); + + this.registerKeyTextData("a", "ㅁ", "ㅁ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("s", "ㄴ", "ㄴ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("d", "ㅇ", "ㅇ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("f", "ㄹ", "ㄹ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("g", "ㅎ", "ㅎ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("h", "ㅗ", "ㅗ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("j", "ㅓ", "ㅓ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("k", "ㅏ", "ㅏ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("l", "ㅣ", "ㅣ", KeyTextData.LEFT_HAND); + + this.registerKeyTextData("z", "ㅋ", "ㅋ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("x", "ㅌ", "ㅌ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("c", "ㅊ", "ㅊ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("v", "ㅍ", "ㅍ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("b", "ㅠ", "ㅠ", KeyTextData.RIGHT_HAND); + this.registerKeyTextData("n", "ㅜ", "ㅜ", KeyTextData.LEFT_HAND); + this.registerKeyTextData("m", "ㅡ", "ㅡ", KeyTextData.LEFT_HAND); + } + +} \ No newline at end of file diff --git a/src/web/client/typing_practice.html b/src/web/client/typing_practice.html index 957df6b..e46e858 100644 --- a/src/web/client/typing_practice.html +++ b/src/web/client/typing_practice.html @@ -51,6 +51,9 @@ + + + diff --git a/test/test_app_info_manager.js b/test/app_info_manager.js similarity index 100% rename from test/test_app_info_manager.js rename to test/app_info_manager.js diff --git a/test/test_db_connect_manager.js b/test/db_connect_manager.js similarity index 100% rename from test/test_db_connect_manager.js rename to test/db_connect_manager.js diff --git a/test/test_heart_manager.js b/test/heart_manager.js similarity index 100% rename from test/test_heart_manager.js rename to test/heart_manager.js diff --git a/test/test_history_record_manager.js b/test/history_record_manager.js similarity index 100% rename from test/test_history_record_manager.js rename to test/history_record_manager.js diff --git a/test/key_mapper.html b/test/key_mapper.html new file mode 100644 index 0000000..824c4ab --- /dev/null +++ b/test/key_mapper.html @@ -0,0 +1,28 @@ + + + + + + Key Mapper + + + +
+
+ + + + + + + + + \ No newline at end of file diff --git a/test/key_mapper.js b/test/key_mapper.js new file mode 100644 index 0000000..8c634e0 --- /dev/null +++ b/test/key_mapper.js @@ -0,0 +1,69 @@ +let englishKeyMapper = new EnglishKeyMapper(); +let koreanKeyMapper = new KoreanKeyMapper(); + + + +QUnit.test( "getNormalText", function( assert ) { + assert.equal(englishKeyMapper.getNormalText("`"), "`", "getNormalText - `"); + assert.equal(englishKeyMapper.getNormalText("/"), "/", "getNormalText - /"); + + assert.equal(englishKeyMapper.getNormalText("q"), "q", "getNormalText - q"); + assert.equal(englishKeyMapper.getNormalText("m"), "m", "getNormalText - m"); + + assert.equal(koreanKeyMapper.getNormalText("q"), "ㅂ", "getNormalText - ㅂ"); + assert.equal(koreanKeyMapper.getNormalText("m"), "ㅡ", "getNormalText - ㅡ"); +}); + +QUnit.test( "getShiftText", function( assert ) { + assert.equal(englishKeyMapper.getShiftText("`"), "~", "getShiftText - ~"); + assert.equal(englishKeyMapper.getShiftText("/"), "?", "getShiftText - ?"); + + assert.equal(englishKeyMapper.getShiftText("q"), "Q", "getShiftText - Q"); + assert.equal(englishKeyMapper.getShiftText("m"), "M", "getShiftText - M"); + + assert.equal(koreanKeyMapper.getShiftText("q"), "ㅃ", "getShiftText - ㅃ"); + assert.equal(koreanKeyMapper.getShiftText("m"), "ㅡ", "getShiftText - ㅡ"); +}); + +QUnit.test( "getShiftHandSide", function( assert ) { + assert.equal(englishKeyMapper.getShiftHandSide("`"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `"); + assert.equal(englishKeyMapper.getShiftHandSide("/"), KeyTextData.LEFT_HAND, "getShiftHandSide - /"); + + assert.equal(englishKeyMapper.getShiftHandSide("space"), KeyTextData.BOTH_HAND, "getShiftHandSide - space"); + + assert.equal(englishKeyMapper.getShiftHandSide("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); + assert.equal(englishKeyMapper.getShiftHandSide("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); + + assert.equal(koreanKeyMapper.getShiftHandSide("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); + assert.equal(koreanKeyMapper.getShiftHandSide("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); +}); + + + +QUnit.test( "getKeyIDOfText", function( assert ) { + assert.equal(englishKeyMapper.getKeyIDOfText("`"), "`", "getKeyIDOfText - `"); + assert.equal(englishKeyMapper.getKeyIDOfText("~"), "`", "getKeyIDOfText - ~"); + assert.equal(englishKeyMapper.getKeyIDOfText("/"), "/", "getKeyIDOfText - /"); + assert.equal(englishKeyMapper.getKeyIDOfText("?"), "/", "getKeyIDOfText - ?"); + + assert.equal(englishKeyMapper.getKeyIDOfText("q"), "q", "getKeyIDOfText - q"); + assert.equal(englishKeyMapper.getKeyIDOfText("Q"), "q", "getKeyIDOfText - Q"); + assert.equal(englishKeyMapper.getKeyIDOfText("m"), "m", "getKeyIDOfText - m"); + assert.equal(englishKeyMapper.getKeyIDOfText("M"), "m", "getKeyIDOfText - M"); + + assert.equal(koreanKeyMapper.getKeyIDOfText("ㅂ"), "q", "getKeyIDOfText - ㅂ"); + assert.equal(koreanKeyMapper.getKeyIDOfText("ㅃ"), "q", "getKeyIDOfText - ㅃ"); + assert.equal(koreanKeyMapper.getKeyIDOfText("ㅡ"), "m", "getKeyIDOfText - ㅡ"); +}); + +QUnit.test( "getShiftTypeOfText", function( assert ) { + assert.equal(englishKeyMapper.getShiftTypeOfText("`"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `"); + assert.equal(englishKeyMapper.getShiftTypeOfText("/"), KeyTextData.LEFT_HAND, "getShiftHandSide - /"); + + assert.equal(englishKeyMapper.getShiftTypeOfText("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); + assert.equal(englishKeyMapper.getShiftTypeOfText("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); + + assert.equal(koreanKeyMapper.getShiftTypeOfText("ㅂ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - ㅂ"); + assert.equal(koreanKeyMapper.getShiftTypeOfText("ㅃ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - ㅃ"); + assert.equal(koreanKeyMapper.getShiftTypeOfText("ㅡ"), KeyTextData.LEFT_HAND, "getShiftHandSide - ㅡ"); +}); diff --git a/test/test_number_util.js b/test/number_util.js similarity index 100% rename from test/test_number_util.js rename to test/number_util.js diff --git a/test/test_ranking_record_manager.js b/test/ranking_record_manager.js similarity index 100% rename from test/test_ranking_record_manager.js rename to test/ranking_record_manager.js diff --git a/test/test_score_manager.js b/test/score_manager.js similarity index 100% rename from test/test_score_manager.js rename to test/score_manager.js diff --git a/test/test_session_storage_manager.js b/test/session_storage_manager.js similarity index 100% rename from test/test_session_storage_manager.js rename to test/session_storage_manager.js diff --git a/test/tests.js b/test/tdd.js similarity index 100% rename from test/tests.js rename to test/tdd.js