diff --git a/pathological-frontend/src/multiplayer_controller.ts b/pathological-frontend/src/multiplayer_controller.ts new file mode 100644 index 0000000..f6fca77 --- /dev/null +++ b/pathological-frontend/src/multiplayer_controller.ts @@ -0,0 +1,31 @@ +import { hostApi } from "./Config"; + +const BASE_URL = hostApi.concat("/api/v1"); + +export class multiplayerController { + async createGame(gameId: string, playerId: string): Promise { + return await fetch(BASE_URL.concat("/multiplayer/game"), { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + player_id: playerId, + game_id: gameId, + }), + }); + } + + async joinGame(gameId: string, playerId: string): Promise { + return await fetch(BASE_URL.concat("/multiplayer/game/join"), { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + player_id: playerId, + game_id: gameId, + }), + }); + } +}