Entering HH in speaking game clears input

This commit is contained in:
Nathan McRae 2024-09-02 20:33:23 -07:00
parent 03c4fb9ea9
commit ba829f344f
2 changed files with 7 additions and 2 deletions

View File

@ -40,7 +40,8 @@ const MORSE_MAP = {
'!': '-.-.--', '!': '-.-.--',
'=': '-...-', '=': '-...-',
'+': '.-.-.', '+': '.-.-.',
'-': '-....-' '-': '-....-',
'clear': '........'
}; };
const REVERSE_MORSE_MAP = function() { const REVERSE_MORSE_MAP = function() {

View File

@ -540,7 +540,11 @@ class InputGame {
// TODO: handle letter being done. // TODO: handle letter being done.
const currentLetterCombo = this.dotAndDashStack.join(''); const currentLetterCombo = this.dotAndDashStack.join('');
if (currentLetterCombo in REVERSE_MORSE_MAP) { if (currentLetterCombo in REVERSE_MORSE_MAP) {
if (REVERSE_MORSE_MAP[currentLetterCombo] == "clear") {
this.letterStack = [];
} else {
this.letterStack.push(REVERSE_MORSE_MAP[currentLetterCombo]); this.letterStack.push(REVERSE_MORSE_MAP[currentLetterCombo]);
}
} else { } else {
// Push a question mark // Push a question mark
this.letterStack.push('?'); this.letterStack.push('?');