mlp-server-tools/tools/test-draft/lobbyapi.mjs

28 lines
687 B
JavaScript
Raw Permalink Normal View History

import axios from "axios";
const APIEndpoint = "http://192.168.20.20/api";
export async function roomList() {
return await axios.get(`${APIEndpoint}/lobby/room/list`);
}
export async function createRoom(roomName, playerName) {
return await axios.post(`${APIEndpoint}/lobby/room/create`, {
game_id: "mlpccg-mcg",
player_name: playerName,
name: roomName,
allow_spectators: true,
max_players: 8,
max_spectators: 10,
tags: ["draft"]
});
}
export async function joinRoom(roomID, playerName, asPlayer = true) {
return await axios.post(`${APIEndpoint}/lobby/room/join`, {
room_id: roomID,
player_name: playerName,
as_player: asPlayer
});
}