diff --git a/src/Game.vue b/src/Game.vue index 7134887..8dc3f80 100644 --- a/src/Game.vue +++ b/src/Game.vue @@ -18,6 +18,7 @@ const board = $ref( }) ) +let message = $ref('') let allowInput = true let currentRowIndex = $ref(0) const currentRow = $computed(() => board[currentRowIndex]) @@ -67,7 +68,7 @@ function completeRow() { if (currentRow.every((tile) => tile.letter)) { const word = currentRow.map((tile) => tile.letter).join('') if (!allWords.includes(word) && word !== answer) { - alert(`"${word}" is not a valid word.`) + showMessage(`Not in word list`) return } @@ -91,20 +92,36 @@ function completeRow() { if (correct) { // yay! allowInput = false - requestIdleCallback(() => alert('yay!')) + showMessage( + ['Genius', 'Magnificent', 'Impressive', 'Splendid', 'Great', 'Phew'][ + currentRowIndex + ] + ) } else if (currentRowIndex < board.length - 1) { // go the next row currentRowIndex++ } else { // game over :( allowInput = false - requestIdleCallback(() => alert('oops')) + showMessage(answer.toUpperCase()) } + } else { + showMessage('Not enough letters') } } + +function showMessage(msg: string) { + message = msg + setTimeout(() => { + message = '' + }, 1000) +}