Merge remote-tracking branch 'refs/remotes/origin/dev' into dev

This commit is contained in:
million1156 2024-03-22 08:58:58 -05:00
commit 321df466d0
2 changed files with 4 additions and 2 deletions

View file

@ -52,7 +52,7 @@
{player.nickname}{#if player !== room.players[room.players.length - 1]},{" "} {player.nickname}{#if player !== room.players[room.players.length - 1]},{" "}
{/if} {/if}
{/each} {/each}
{/if} | {room.hasPassword ? "Private" : "Public"} | {room.address}:{room.port} {/if} | {room.hasPassword ? "Private" : "Public"}
</div> </div>
</div> </div>
</div> </div>

View file

@ -5,6 +5,7 @@ import { useAuth } from "$lib/util/api/index.js";
/* thanks again janeberru for the shape of this data */ /* thanks again janeberru for the shape of this data */
export async function POST({ request, params }) { export async function POST({ request, params }) {
const body = await request.json(); const body = await request.json();
console.log(body);
const { id } = params; const { id } = params;
const room = RoomManager.getRoom(id); const room = RoomManager.getRoom(id);
if (!room) return new Response(null, { status: 500 }); if (!room) return new Response(null, { status: 500 });
@ -12,8 +13,9 @@ export async function POST({ request, params }) {
if (!user) return new Response(null, { status: 401 }); if (!user) return new Response(null, { status: 401 });
if (user.id !== room.host.id) return new Response(null, { status: 401 }); if (user.id !== room.host.id) return new Response(null, { status: 401 });
if (body.players.length === 0 && room.roomInfo.owner) { if (body.players.length === 0 && room.roomInfo.owner) {
console.log(room.roomInfo.players);
room.setPlayerList([{ gameId: 0, gameName: "", nickname: room.roomInfo.owner }]); room.setPlayerList([{ gameId: 0, gameName: "", nickname: room.roomInfo.owner }]);
} else {
room.setPlayerList(body.players);
} }
return json({ message: "Lobby updated successfully" }); return json({ message: "Lobby updated successfully" });
} }