Feat : allow buying cards
This commit is contained in:
+48
-29
@@ -48,45 +48,64 @@ export async function whoami() {
|
||||
|
||||
export async function createGame() {
|
||||
const config = useRuntimeConfig();
|
||||
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",
|
||||
});
|
||||
}
|
||||
|
||||
export async function endTurn(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch(
|
||||
new URL(`games/${game}/endTurn`, 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",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function endTurn(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch(new URL(`games/${game}/endTurn`, config.public.endpoint).href, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
}
|
||||
|
||||
export async function lockCard(game: string, cardId: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch(
|
||||
new URL(`games/${game}/turn/lockCard/${cardId}`, config.public.endpoint).href,
|
||||
new URL(`games/${game}/turn/lockCard/${cardId}`, config.public.endpoint)
|
||||
.href,
|
||||
{
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function buyCard(game: string, cardId: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch(
|
||||
new URL(`games/${game}/turn/buyCard/${cardId}`, config.public.endpoint)
|
||||
.href,
|
||||
{
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
|
||||
Reference in New Issue
Block a user