fix(ui): lower-case hint preview words to match evaluate
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 52s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m20s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 52s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m20s
A hint's MoveRecord words are upper-cased on decode (for the move-history view), whereas an EvalResult keeps the backend's lower case. Seeding the move preview from the hint verbatim flipped the score caption to upper case and nudged its height. Lower-case the words in previewFromHint so the caption reads the same as the evaluate path it replaces.
This commit is contained in:
@@ -107,7 +107,7 @@ describe('placementFromHint', () => {
|
||||
});
|
||||
|
||||
describe('previewFromHint', () => {
|
||||
it('reuses the hint move as a legal preview, carrying score, words and direction', () => {
|
||||
it('reuses the hint move as a legal preview, lower-casing words to match evaluate', () => {
|
||||
const preview = previewFromHint({
|
||||
player: 0,
|
||||
action: 'play',
|
||||
@@ -120,7 +120,7 @@ describe('previewFromHint', () => {
|
||||
score: 18,
|
||||
total: 42,
|
||||
});
|
||||
expect(preview).toEqual({ legal: true, score: 18, words: ['CAT', 'AN'], dir: 'V' });
|
||||
expect(preview).toEqual({ legal: true, score: 18, words: ['cat', 'an'], dir: 'V' });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -59,10 +59,13 @@ export function placementFromHint(tiles: Tile[], rack: string[]): Placement {
|
||||
* previewFromHint turns a hint's move into a move preview. A hint is the engine's own
|
||||
* top-ranked, fully scored legal play, so its move already carries the score, words and
|
||||
* direction an evaluate would compute for the same placement; reusing it lets the client
|
||||
* skip a redundant evaluate round-trip after auto-placing the hint.
|
||||
* skip a redundant evaluate round-trip after auto-placing the hint. The words are
|
||||
* lower-cased to match the evaluate result the caption renders: a hint's MoveRecord words
|
||||
* are upper-cased on decode (for the move-history view), whereas an EvalResult keeps the
|
||||
* backend's lower case, so reusing them verbatim would otherwise change the caption's case.
|
||||
*/
|
||||
export function previewFromHint(move: MoveRecord): EvalResult {
|
||||
return { legal: true, score: move.score, words: move.words, dir: move.dir };
|
||||
return { legal: true, score: move.score, words: move.words.map((w) => w.toLowerCase()), dir: move.dir };
|
||||
}
|
||||
|
||||
function usedIndexes(p: Placement): Set<number> {
|
||||
|
||||
Reference in New Issue
Block a user