Feat : allow buying cards

This commit is contained in:
2024-07-05 11:26:41 +02:00
parent 694e8429d1
commit b3df241313
6 changed files with 134 additions and 70 deletions
+48 -29
View File
@@ -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",