feat(ui): name the previous player in the your-turn toast
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 46s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 58s
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 46s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 58s
The in-app "your turn" toast (shown when it becomes your turn in another game) now reads "<Opponent>: Your turn!", naming the player who moved just before this one — the previous seat in turn order, so it reads the same in games with any number of players. Falls back to the bare "Your turn" label when no name is present (an older peer, or a gap event without one). YourTurnEvent already carries opponent_name end to end: the backend sets it (game.displayName of the last mover) and the gateway forwards the payload opaquely, so this is a client-only change — decode the field, thread it through PushEvent, and pick the localized string.
This commit is contained in:
@@ -300,6 +300,39 @@ describe('codec', () => {
|
||||
expect(inv.variant).toBe('scrabble_en');
|
||||
});
|
||||
|
||||
it('decodes a your_turn event, carrying the previous player name for the toast', () => {
|
||||
const b = new Builder(64);
|
||||
const gid = b.createString('g-1');
|
||||
const name = b.createString('Ann');
|
||||
fb.YourTurnEvent.startYourTurnEvent(b);
|
||||
fb.YourTurnEvent.addGameId(b, gid);
|
||||
fb.YourTurnEvent.addOpponentName(b, name);
|
||||
fb.YourTurnEvent.addMoveCount(b, 7);
|
||||
b.finish(fb.YourTurnEvent.endYourTurnEvent(b));
|
||||
expect(decodeEvent('your_turn', b.asUint8Array())).toEqual({
|
||||
kind: 'your_turn',
|
||||
gameId: 'g-1',
|
||||
deadlineUnix: 0,
|
||||
opponentName: 'Ann',
|
||||
moveCount: 7,
|
||||
});
|
||||
});
|
||||
|
||||
it('decodes a your_turn event with no opponent name as an empty string', () => {
|
||||
const b = new Builder(64);
|
||||
const gid = b.createString('g-2');
|
||||
fb.YourTurnEvent.startYourTurnEvent(b);
|
||||
fb.YourTurnEvent.addGameId(b, gid);
|
||||
b.finish(fb.YourTurnEvent.endYourTurnEvent(b));
|
||||
expect(decodeEvent('your_turn', b.asUint8Array())).toEqual({
|
||||
kind: 'your_turn',
|
||||
gameId: 'g-2',
|
||||
deadlineUnix: 0,
|
||||
opponentName: '',
|
||||
moveCount: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('decodes an opponent_joined event (reusing the match_found payload layout)', () => {
|
||||
const b = new Builder(64);
|
||||
const gid = b.createString('g-open');
|
||||
|
||||
Reference in New Issue
Block a user