diff --git a/src/lib/server/class/Room.ts b/src/lib/server/class/Room.ts index 2852066..5c6fa5e 100644 --- a/src/lib/server/class/Room.ts +++ b/src/lib/server/class/Room.ts @@ -4,7 +4,7 @@ import type { SuyuUser } from "../schema"; import { v4 } from "uuid"; export class RoomManager { - private static rooms: Room[] = []; + static rooms: Room[] = []; static roomTimeout: Record = {}; // room id, last heard from static createRoom(room: IRoomConfig) { const existingRoom = this.rooms.find((r) => r.host.username === room.host.username); diff --git a/src/routes/lobby/+server.ts b/src/routes/lobby/+server.ts index bd1b0c6..ca258a9 100644 --- a/src/routes/lobby/+server.ts +++ b/src/routes/lobby/+server.ts @@ -66,5 +66,11 @@ export async function POST({ request, getClientAddress }) { hasPassword: body.hasPassword || false, }); console.log("Room added:", JSON.stringify(room, null, 2)); + // push every room to the top which starts with `[SUYU OFFICIAL]` and was created with username "suyu" + const suyuRoom = RoomManager.rooms.find((r) => r.roomInfo.name.startsWith("[SUYU OFFICIAL]")); + if (suyuRoom && user.username === "suyu") { + RoomManager.rooms.splice(RoomManager.rooms.indexOf(suyuRoom), 1); + RoomManager.rooms.unshift(suyuRoom); + } return json(room.toJSON()); }