Skip to content

Commit dc03a27

Browse files
committed
games: Re-add info to Scrabble plays
1 parent bfe8236 commit dc03a27

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/ps/games/scrabble/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export class Scrabble extends Game<State> {
248248
action: 'play',
249249
time: new Date(),
250250
turn,
251-
ctx: { points, tiles, point: pos, dir, rack, newTiles, words: words.map(word => word.word) },
251+
ctx: { points, tiles, point: pos, dir, rack, newTiles, words: points.words },
252252
};
253253
this.log.push(logEntry);
254254
this.room.sendHTML(...renderMove(logEntry, this));

src/ps/games/scrabble/logs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ export type Log = Satisfies<
1212
} & (
1313
| {
1414
action: 'play';
15-
ctx: { points: Points; tiles: BoardTile[]; dir: DIRECTION; point: Point; newTiles: string[]; rack: string[]; words: string[] };
15+
ctx: {
16+
points: Points;
17+
tiles: BoardTile[];
18+
dir: DIRECTION;
19+
point: Point;
20+
newTiles: string[];
21+
rack: string[];
22+
words: Record<string, number>;
23+
};
1624
}
1725
| { action: 'exchange'; ctx: { tiles: string[]; newTiles: string[]; rack: string[] } }
1826
| { action: 'pass'; ctx: { rack: string[] } }

src/ps/games/scrabble/render.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ export function renderMove(logEntry: Log, { id, players, $T, renderCtx: { msg }
2727

2828
switch (logEntry.action) {
2929
case 'play':
30+
const words = Object.entries(logEntry.ctx.words);
3031
return [
3132
<Wrapper>
32-
<Username name={playerName} /> played {logEntry.ctx.words.list($T)} for {logEntry.ctx.points.total} points!
33+
<Username name={playerName} /> played{' '}
34+
{words.length === 1 && !logEntry.ctx.points.bingo
35+
? words[0][0]
36+
: words.map(([word, points]) => `${word} (${points})`).list($T)}{' '}
37+
for {logEntry.ctx.points.total} points!
3338
{logEntry.ctx.points.bingo ? ' BINGO!' : null}
3439
</Wrapper>,
3540
opts,

0 commit comments

Comments
 (0)