Skip to content

Commit

Permalink
Revert buy endpoint mapId selection
Browse files Browse the repository at this point in the history
  • Loading branch information
hopperelec committed Feb 29, 2024
1 parent bd63cca commit 6aa88da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/routes/game/[gameId=id]/shop/[itemId=id]/buy/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ACTIONS: { [key: string]: (details: ActionDetails) => Promise<boolean> } =
const player = await prisma.player.findUnique({
where: { id: playerId },
select: {
game: { select: { id: true } },
game: { select: { id: true, mapId: true } },
},
});
if (!player)
Expand All @@ -42,7 +42,7 @@ const ACTIONS: { [key: string]: (details: ActionDetails) => Promise<boolean> } =
"An unexpected error occurred while trying to retrieve your player data",
);
const rooms: { id: bigint }[] =
await prisma.$queryRaw`SELECT id FROM Room WHERE mapId = (SELECT mapId from Game WHERE id=${player.game.id}) ORDER BY rand() LIMIT 1`;
await prisma.$queryRaw`SELECT id FROM Room WHERE mapId = ${player.game.mapId} ORDER BY rand() LIMIT 1`;
if (rooms.length === 0) return false;
await moveRoom(user.id, playerId, player.game.id, Number(rooms[0].id));
return true;
Expand Down

0 comments on commit 6aa88da

Please sign in to comment.