Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore earlier guessed words #139

Open
stelian56 opened this issue Feb 1, 2023 · 0 comments
Open

Ignore earlier guessed words #139

stelian56 opened this issue Feb 1, 2023 · 0 comments

Comments

@stelian56
Copy link

stelian56 commented Feb 1, 2023

It is proposed that guessed words be stored in the app's local storage and not used as challenges anymore. Code changes to Game.tsx:

var usedWords = JSON.parse(localStorage.getItem('usedWords') || '[]');

function randomTarget(wordLength: number): string {
  const eligible = targets.filter((word) => word.length === wordLength
    && !(usedWords.includes(word)));
  . . .

  const onKey = (key: string) => {
  . . .
    const saveUsedWord = (word: string) => {
        usedWords.push(target);
        localStorage.setItem('usedWords', JSON.stringify(usedWords));
    };
      
    if (currentGuess === target) {
      setHint(gameOver("won"));
      setGameState(GameState.Won);
      saveUsedWord(target);
    }
    . . .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant