Skip to content

Commit b8dca24

Browse files
committed
scrabble: Fix logs and pass counts
1 parent 6dda47e commit b8dca24

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/ps/games/scrabble/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,12 @@ 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: points.words },
251+
ctx: { points, tiles, point: pos, dir, rack: rack.slice(), newTiles, words: points.words },
252252
};
253253
this.log.push(logEntry);
254254
this.room.sendHTML(...renderMove(logEntry, this));
255255
this.selected = null;
256+
this.passCount = 0;
256257

257258
if (rack.length === 0) return this.end();
258259
const next = this.nextPlayer();
@@ -289,7 +290,8 @@ export class Scrabble extends Game<State> {
289290
rack.push(...newTiles);
290291
if (newTiles.includes('_')) this.room.privateSend(turn, this.$T('GAME.SCRABBLE.HOW_TO_BLANK'));
291292

292-
const logEntry: Log = { action: 'exchange', time: new Date(), turn, ctx: { tiles: letters, newTiles, rack } };
293+
this.passCount = 0;
294+
const logEntry: Log = { action: 'exchange', time: new Date(), turn, ctx: { tiles: letters, newTiles, rack: rack.slice() } };
293295
this.log.push(logEntry);
294296
this.room.sendHTML(...renderMove(logEntry, this));
295297

@@ -300,7 +302,7 @@ export class Scrabble extends Game<State> {
300302
const turn = this.turn!;
301303
this.passCount ??= 0;
302304
this.passCount++;
303-
const logEntry: Log = { action: 'pass', time: new Date(), turn, ctx: { rack: this.state.racks[turn] } };
305+
const logEntry: Log = { action: 'pass', time: new Date(), turn, ctx: { rack: this.state.racks[turn].slice() } };
304306
this.log.push(logEntry);
305307
this.room.sendHTML(...renderMove(logEntry, this));
306308
if (this.passCount > Object.keys(this.players).length) {
@@ -356,10 +358,9 @@ export class Scrabble extends Game<State> {
356358
getPoints: tile => this.points[tile],
357359
rack: side ? this.state.racks[side] : undefined,
358360
players: Object.fromEntries(
359-
Object.values(this.players).map(({ id, name, out }) => [
360-
id,
361-
{ id, name, score: this.state.score[id], rack: this.state.racks[id].length, out },
362-
])
361+
this.turns
362+
.map(turn => this.players[turn])
363+
.map(({ id, name, out }) => [id, { id, name, score: this.state.score[id], rack: this.state.racks[id].length, out }])
363364
),
364365
isActive,
365366
side,
@@ -380,6 +381,10 @@ export class Scrabble extends Game<State> {
380381
return render.bind(this.renderCtx)(ctx);
381382
}
382383

384+
getURL() {
385+
return null;
386+
}
387+
383388
async renderEmbed(): Promise<EmbedBuilder | null> {
384389
const winners = this.winCtx && this.winCtx.type === 'win' ? this.winCtx.winnerIds : null;
385390
if (!winners) return null;

0 commit comments

Comments
 (0)