add update game endpoint
This commit is contained in:
@ -47,13 +47,6 @@ export const PUT: RequestHandler = async ({ params, request }): Promise<Response
|
||||
const game = Game.from(listing.data);
|
||||
if (game.setPlayerReady(player) === null) return notFoundResponse();
|
||||
|
||||
// TODO: there's a potential race condition here where some player is unreadying as this
|
||||
// function is running. This should do some kind of check in MongoDB to make sure
|
||||
// all players are ready if it's starting the game. For now: good enough.
|
||||
if (game.players.every(({ isReady }) => isReady)) {
|
||||
game.start();
|
||||
}
|
||||
|
||||
await writeUpdatedListing(ServerCollections.Games, updateListing(listing, game));
|
||||
|
||||
return singleResponse(game);
|
||||
|
Reference in New Issue
Block a user