Skip to content

Commit

Permalink
WIP multiplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
yazan-abu-obaideh committed Nov 24, 2024
1 parent 4e412ca commit 17d0919
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pathological-frontend/src/multiplayer_controller.ts
Original file line number Diff line number Diff line change
@@ -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<Response> {
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<Response> {
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,
}),
});
}
}

0 comments on commit 17d0919

Please sign in to comment.