From ba829f344f0aeecaedf15b099e1a8a1a05fe73de Mon Sep 17 00:00:00 2001 From: Nathan McRae Date: Mon, 2 Sep 2024 20:33:23 -0700 Subject: [PATCH] Entering HH in speaking game clears input --- morse-code_files/constants.js | 3 ++- morse-code_files/morse-code.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/morse-code_files/constants.js b/morse-code_files/constants.js index 6efd9a7..71675e2 100644 --- a/morse-code_files/constants.js +++ b/morse-code_files/constants.js @@ -40,7 +40,8 @@ const MORSE_MAP = { '!': '-.-.--', '=': '-...-', '+': '.-.-.', - '-': '-....-' + '-': '-....-', + 'clear': '........' }; const REVERSE_MORSE_MAP = function() { diff --git a/morse-code_files/morse-code.js b/morse-code_files/morse-code.js index 23778fb..63acc37 100644 --- a/morse-code_files/morse-code.js +++ b/morse-code_files/morse-code.js @@ -540,7 +540,11 @@ class InputGame { // TODO: handle letter being done. const currentLetterCombo = this.dotAndDashStack.join(''); if (currentLetterCombo in REVERSE_MORSE_MAP) { - this.letterStack.push(REVERSE_MORSE_MAP[currentLetterCombo]); + if (REVERSE_MORSE_MAP[currentLetterCombo] == "clear") { + this.letterStack = []; + } else { + this.letterStack.push(REVERSE_MORSE_MAP[currentLetterCombo]); + } } else { // Push a question mark this.letterStack.push('?');