From bf88336a1accf5d4def4066b021d63bc7e228aad Mon Sep 17 00:00:00 2001 From: Hugo Montenegro Date: Sun, 15 Mar 2026 21:43:33 +0000 Subject: [PATCH] fix: hard mode now treats diacritics as equivalent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hard mode was rejecting valid guesses like "barão" when a previous guess had "ã" in the correct position, because it compared characters literally (ã !== a). Now uses the language's diacritic normalize map via charsMatch/normalizeChar, consistent with how the color algorithm already handles diacritics. --- stores/game.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stores/game.ts b/stores/game.ts index 38496523..13bc08ef 100644 --- a/stores/game.ts +++ b/stores/game.ts @@ -17,7 +17,12 @@ import { defineStore } from 'pinia'; import { useLanguageStore } from '~/stores/language'; import { useSettingsStore } from '~/stores/settings'; import { useStatsStore } from '~/stores/stats'; -import { buildNormalizedWordMap, normalizeWord } from '~/utils/diacritics'; +import { + buildNormalizedWordMap, + charsMatch, + normalizeChar, + normalizeWord, +} from '~/utils/diacritics'; import { toFinalForm, toRegularForm } from '~/utils/positional'; import { splitWord } from '~/utils/graphemes'; import { calculateCommunityPercentile } from '~/utils/stats'; @@ -967,6 +972,9 @@ export const useGameStore = defineStore('game', () => { * Returns an error message if invalid, or null if valid. */ function checkHardMode(guess: string): string | null { + const lang = useLanguageStore(); + const nMap = lang.normalizeMap; + for (let r = 0; r < activeRow.value; r++) { const row = tiles.value[r]; const colors = tileColors.value[r]; @@ -978,11 +986,15 @@ export const useGameStore = defineStore('game', () => { if (!letter) continue; if (color === 'correct') { - if (guess[c]?.toLowerCase() !== letter.toLowerCase()) { + if (!charsMatch(guess[c] || '', letter, nMap)) { return `Hard mode: ${letter.toUpperCase()} must be in position ${c + 1}`; } } else if (color === 'semicorrect') { - if (!guess.toLowerCase().includes(letter.toLowerCase())) { + const normalizedLetter = normalizeChar(letter, nMap).toLowerCase(); + const guessHasLetter = [...guess].some( + (g) => normalizeChar(g, nMap).toLowerCase() === normalizedLetter + ); + if (!guessHasLetter) { return `Hard mode: guess must contain ${letter.toUpperCase()}`; } }