|
@@ -15,18 +15,18 @@ export function createPlayAgainRouter(wordBank: WordBank, cache: Map<number, Cac
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const target = selectPlayAgainWord(wordBank.targets, skillMetric, cache);
|
|
|
|
|
- res.json({ wordId: target.id });
|
|
|
|
|
|
|
+ const { target, index } = selectPlayAgainWord(wordBank.targets, skillMetric, cache);
|
|
|
|
|
+ res.json({ wordId: index });
|
|
|
|
|
|
|
|
// Pre-warm cache so solver replays are ready (or nearly ready) by the time
|
|
// Pre-warm cache so solver replays are ready (or nearly ready) by the time
|
|
|
// the player finishes their last guess.
|
|
// the player finishes their last guess.
|
|
|
- if (!cache.has(target.id)) {
|
|
|
|
|
- cache.set(target.id, computeReplays(target.word, wordBank.guessable));
|
|
|
|
|
|
|
+ if (!cache.has(index)) {
|
|
|
|
|
+ cache.set(index, computeReplays(target.word, wordBank.guessable));
|
|
|
|
|
|
|
|
const targetWord = target.word;
|
|
const targetWord = target.word;
|
|
|
const guessable = wordBank.guessable;
|
|
const guessable = wordBank.guessable;
|
|
|
runSolverInWorker({ target: targetWord, allWords: guessable, mode: 'full' })
|
|
runSolverInWorker({ target: targetWord, allWords: guessable, mode: 'full' })
|
|
|
- .then((full) => { cache.set(target.id, full); })
|
|
|
|
|
|
|
+ .then((full) => { cache.set(index, full); })
|
|
|
.catch((err) => { console.error('Solver worker failed:', err); });
|
|
.catch((err) => { console.error('Solver worker failed:', err); });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|