Skip to content

Commit 0914551

Browse files
committed
games: Handle subs for Snakes & Ladders
1 parent 7a365aa commit 0914551

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/ps/games/snakesladders/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ export class SnakesLadders extends BaseGame<State> {
5555
return { success: true, data: null };
5656
}
5757

58+
onReplacePlayer(turn: string, withPlayer: User): ActionResponse {
59+
const oldBoardPlayer = this.state.board[turn];
60+
if (!oldBoardPlayer) return { success: false, error: 'Could not find old player' as ToTranslate };
61+
delete this.state.board[turn];
62+
this.state.board[withPlayer.id] = { ...oldBoardPlayer, name: withPlayer.name };
63+
return { success: true, data: null };
64+
}
65+
5866
action(user: User): void {
5967
if (!this.started) this.throw('GAME.NOT_STARTED');
6068
if (user.id !== this.players[this.turn!].id) this.throw('GAME.IMPOSTOR_ALERT');

src/web/loaders/static.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import express, { type Application } from 'express';
1+
import { type Application, static as expressStatic } from 'express';
22

33
import { fsPath } from '@/utils/fsPath';
44

55
export default async function init(app: Application): Promise<void> {
66
app.get('/styles.css', (req, res) => res.sendFile(fsPath('web', 'react', 'compiled', 'styles.css')));
77
app.get('/favicon.ico', (req, res) => res.sendFile(fsPath('web', 'assets', 'favicon.ico')));
8-
app.use('/static', express.static(fsPath('web', 'static')));
8+
app.use('/static', expressStatic(fsPath('web', 'static')));
99
}

0 commit comments

Comments
 (0)