Skip to content

Commit 18ae161

Browse files
committed
games: Render SL players in turn order
1 parent e2f961a commit 18ae161

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/ps/games/snakesladders/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export class SnakesLadders extends BaseGame<State> {
136136
override && this.turn
137137
? { ...this.state.board, [this.turn]: { ...this.state.board[this.turn], pos: override } }
138138
: this.state.board,
139+
turns: this.turns,
139140
lastRoll: this.state.lastRoll,
140141
id: this.id,
141142
active: side === this.turn && !!side,

src/ps/games/snakesladders/render.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export function render(this: This, ctx: RenderCtx): ReactElement {
9191
) : null}
9292
<br />
9393
<br />
94-
{Object.values(ctx.board)
94+
{ctx.turns
95+
.map(id => ctx.board[id])
9596
.map(player => (
9697
<>
9798
<Player color={player.color} as="div" /> <Username name={player.name} clickable />

src/ps/games/snakesladders/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type State = {
88

99
export type RenderCtx = {
1010
id: string;
11+
turns: string[];
1112
board: Board;
1213
lastRoll: number;
1314
active?: boolean;

0 commit comments

Comments
 (0)