From 17d09194d379e7c734e7ff6231406aabb61161c2 Mon Sep 17 00:00:00 2001 From: Yazan Amer Date: Thu, 21 Nov 2024 12:47:21 +0100 Subject: [PATCH] WIP multiplayer --- .../src/multiplayer_controller.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pathological-frontend/src/multiplayer_controller.ts 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, + }), + }); + } +}