mirror of
https://git.suyu.dev/suyu/website.git
synced 2026-01-04 21:54:48 +01:00
blarghh
This commit is contained in:
parent
5351c54d8d
commit
f56d94bffc
4 changed files with 69 additions and 1 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import { db } from "$lib/server/db";
|
||||
import "reflect-metadata";
|
||||
import { building } from "$app/environment";
|
||||
import type { Handle } from "@sveltejs/kit";
|
||||
|
||||
const runAllTheInitFunctions = async () => {
|
||||
await db.initialize();
|
||||
if (!db.isInitialized) await db.initialize();
|
||||
};
|
||||
|
||||
if (!building) {
|
||||
|
|
|
|||
37
src/lib/server/class/Room.ts
Normal file
37
src/lib/server/class/Room.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import type { IRoom } from "$types/rooms";
|
||||
import type { SuyuUser } from "../schema";
|
||||
|
||||
export class Room {
|
||||
public roomInfo: IRoom;
|
||||
constructor(
|
||||
name: string,
|
||||
description: string,
|
||||
game: string,
|
||||
players: SuyuUser[],
|
||||
maxPlayers: number,
|
||||
) {
|
||||
this.roomInfo = {
|
||||
name,
|
||||
description,
|
||||
preferredGameName: game,
|
||||
players,
|
||||
maxPlayers,
|
||||
address: "localhost",
|
||||
externalGuid: "1234",
|
||||
hasPassword: false,
|
||||
id: "1234",
|
||||
netVersion: 1,
|
||||
owner: "1234",
|
||||
port: 1234,
|
||||
preferredGameId: 1234,
|
||||
};
|
||||
}
|
||||
|
||||
async addPlayer(user: SuyuUser) {
|
||||
this.roomInfo.players.push(user);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.roomInfo;
|
||||
}
|
||||
}
|
||||
9
src/routes/lobby/+server.ts
Normal file
9
src/routes/lobby/+server.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { Room } from "$lib/server/class/Room";
|
||||
import { json } from "$lib/server/util";
|
||||
import type { LobbyResponse } from "$types/rooms";
|
||||
|
||||
export async function GET({ request }) {
|
||||
return json<LobbyResponse>({
|
||||
rooms: [new Room("suyu Testing Room 1", "A testing room for suyu", "suyu", [], 4).toJSON()],
|
||||
});
|
||||
}
|
||||
21
src/types/rooms.d.ts
vendored
Normal file
21
src/types/rooms.d.ts
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import type { SuyuUser } from "$lib/server/schema";
|
||||
|
||||
export interface IRoom {
|
||||
address: string;
|
||||
description: string;
|
||||
externalGuid: string;
|
||||
hasPassword: boolean;
|
||||
id: string;
|
||||
maxPlayers: number;
|
||||
name: string;
|
||||
netVersion: number;
|
||||
owner: string;
|
||||
players: SuyuUser[];
|
||||
port: number;
|
||||
preferredGameId: number;
|
||||
preferredGameName: string;
|
||||
}
|
||||
|
||||
export interface LobbyResponse {
|
||||
rooms: IRoom[];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue