Feat : card distribute
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import type { Container } from "./interfaces";
|
||||
import type { CardParser } from "./interfaces/cards";
|
||||
|
||||
export type ContainerHandler = {
|
||||
populateContainer: () => void;
|
||||
shuffleContainer: () => void;
|
||||
getCardsPosition: (cards: string) => any;
|
||||
hideCards: (cards: CardParser[]) => void;
|
||||
showCards: (cards: CardParser[]) => void;
|
||||
};
|
||||
|
||||
export const containerEvents = new Map<string, ContainerHandler>();
|
||||
+22
-8
@@ -25,28 +25,42 @@ export async function getLobby() {
|
||||
|
||||
export async function whoami() {
|
||||
const config = useRuntimeConfig();
|
||||
const req = await useFetch<User>(
|
||||
const { data, pending, error, refresh } = await useFetch<User>(
|
||||
new URL("/whoami", config.public.endpoint).href,
|
||||
{
|
||||
credentials: "include",
|
||||
}
|
||||
);
|
||||
if (
|
||||
req.error.value?.statusCode &&
|
||||
[401].includes(req.error.value.statusCode)
|
||||
) {
|
||||
if (error.value?.statusCode && [401].includes(error.value.statusCode)) {
|
||||
// await navigateTo(config.public.discordLoginEndpoint, {
|
||||
// external: true,
|
||||
// });
|
||||
throw new Error("You are not logged in");
|
||||
}
|
||||
if (req.error.value) {
|
||||
if (error.value) {
|
||||
throw new Error(
|
||||
"Something went wrong while trying to get user information"
|
||||
);
|
||||
}
|
||||
|
||||
return req.data;
|
||||
return data;
|
||||
}
|
||||
|
||||
export function createGame() {}
|
||||
export async function createGame() {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch<User>(new URL("/games", config.public.endpoint).href, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
}
|
||||
|
||||
export async function endTurn(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
await $fetch<User>(
|
||||
new URL(`games/${game}/endTurn`, config.public.endpoint).href,
|
||||
{
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user