Feat : various fixes, sounds and multiplayer additions
This commit is contained in:
+21
-3
@@ -48,7 +48,25 @@ export async function whoami() {
|
||||
|
||||
export async function createGame() {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch<User>(new URL("/games", config.public.endpoint).href, {
|
||||
const res = await $fetch<Game>(new URL("/games", config.public.endpoint).href, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
console.log(res)
|
||||
navigateTo("/game/" + res._id)
|
||||
}
|
||||
|
||||
export async function startGame(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
const res = await $fetch<Game>(new URL(`games/${game}/start`, config.public.endpoint).href, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
}
|
||||
|
||||
export async function joinGame(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
const res = await $fetch<Game>(new URL(`games/${game}/join`, config.public.endpoint).href, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
@@ -56,7 +74,7 @@ export async function createGame() {
|
||||
|
||||
export async function endTurn(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch<User>(
|
||||
await $fetch(
|
||||
new URL(`games/${game}/endTurn`, config.public.endpoint).href,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -67,7 +85,7 @@ export async function endTurn(game: string) {
|
||||
|
||||
export async function lockCard(game: string, cardId: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch<User>(
|
||||
await $fetch(
|
||||
new URL(`games/${game}/turn/lockCard/${cardId}`, config.public.endpoint).href,
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
@@ -16,10 +16,13 @@ export interface Game extends GameObject {
|
||||
marketStack: Container;
|
||||
teams: Team[];
|
||||
currentTurn: PlayingTurn;
|
||||
started: boolean
|
||||
owner: User
|
||||
}
|
||||
|
||||
export interface Team extends GameObject {
|
||||
players: Player[];
|
||||
health: number;
|
||||
}
|
||||
|
||||
export interface Player extends GameObject {
|
||||
@@ -28,10 +31,14 @@ export interface Player extends GameObject {
|
||||
hand: Container;
|
||||
stack: Container;
|
||||
user: User;
|
||||
discardMarkers: number
|
||||
fuckUMarkers: number
|
||||
}
|
||||
|
||||
export interface User extends GameObject {
|
||||
userId: string;
|
||||
avatar: string;
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface Container extends GameObject {
|
||||
|
||||
Reference in New Issue
Block a user