From a3e7e835223b22bd8dc830892687b7aced618a93 Mon Sep 17 00:00:00 2001 From: Andre Padez Date: Wed, 5 Nov 2025 10:28:02 +0000 Subject: [PATCH] Use sequential selection for sentences and paragraphs instead of random - Track sentenceIndex and paragraphIndex for sequential selection - Sentences and paragraphs now appear in order, cycling through the list - Letters and words remain randomized as before --- src/wordLists.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/wordLists.ts b/src/wordLists.ts index 0cbe19c..ebb02e5 100644 --- a/src/wordLists.ts +++ b/src/wordLists.ts @@ -37,6 +37,10 @@ export const wordLists = { ] as const, }; +// Track current index for sequential selection in sentences/paragraphs +let sentenceIndex = 0; +let paragraphIndex = 0; + export function getRandomItem(array: readonly T[]): T { return array[Math.floor(Math.random() * array.length)]; } @@ -45,5 +49,20 @@ export function getRandomWord(gameMode: 'letters' | 'words' | 'sentences' | 'par // Use custom list if provided, otherwise use default for the game mode // Letters mode always uses default alphabet const list = customList && gameMode !== 'letters' ? customList : wordLists[gameMode]; + + // For sentences and paragraphs, use sequential selection instead of random + if (gameMode === 'sentences') { + const result = String(list[sentenceIndex % list.length]); + sentenceIndex++; + return result; + } + + if (gameMode === 'paragraphs') { + const result = String(list[paragraphIndex % list.length]); + paragraphIndex++; + return result; + } + + // For letters and words, keep randomization return String(getRandomItem(list)); }