diff --git a/src/clientGame.ts b/src/clientGame.ts index db02d09..07ac7d7 100644 --- a/src/clientGame.ts +++ b/src/clientGame.ts @@ -2,10 +2,11 @@ import { defineStore } from "pinia" import { EventBusKey, useEventBus } from "@vueuse/core" import type { GameAction } from "./shared/game/actions" import { computed, reactive, readonly, ref } from "vue" -import { GameState, getUninitializedGameState, produceNewState } from "./shared/game/state" +import { GameState, getNumberCardsSum, getUninitializedGameState, produceNewState } from "./shared/game/state" import { trpcClient } from "./trpc" import { useAuth } from "./auth" import { read } from "fs" +import type { SpecialCardId } from "./shared/game/cards" const gameActionsBusKey = Symbol() as EventBusKey const useGameActionsBus = () => useEventBus(gameActionsBusKey) @@ -63,6 +64,8 @@ export const useGame = defineStore("game", () => { lobbyCode: readonly(lobbyCode), isActive: computed(() => lobbyCode.value !== null), isOwnGame: computed(() => state.value.players.findIndex(p => p.id === (auth.authenticatedUser?.id ?? "")) === 0), + isYourTurn: computed(() => state.value.activePlayerId === auth.requiredUser.id), + isBust: computed(() => getNumberCardsSum(state.value.players.find(p => p.id === auth.requiredUser.id)!.numberCards) > state.value.targetSum), state: readonly(state), actions: readonly(actions), join, @@ -75,6 +78,7 @@ export const useGame = defineStore("game", () => { start: () => trpcClient.game.start.mutate({ lobbyCode: lobbyCode.value! }), hit: () => trpcClient.game.hit.mutate({ lobbyCode: lobbyCode.value! }), stay: () => trpcClient.game.stay.mutate({ lobbyCode: lobbyCode.value! }), + useSpecialCard: (id: SpecialCardId) => trpcClient.game.useSpecialCard.mutate({ lobbyCode: lobbyCode.value!, specialCardId: id }), newRound: () => trpcClient.game.newRound.mutate({ lobbyCode: lobbyCode.value! }), create: () => trpcClient.createGame.mutate() } diff --git a/src/components/Card.vue b/src/components/Card.vue index 6cda4f7..e411d6b 100644 --- a/src/components/Card.vue +++ b/src/components/Card.vue @@ -1,5 +1,5 @@ @@ -38,6 +42,7 @@ icon: FunctionalComponent }>>, default: [] - } + }, + asButton: Boolean }) \ No newline at end of file diff --git a/src/components/Game.vue b/src/components/Game.vue index 45005d8..1479795 100644 --- a/src/components/Game.vue +++ b/src/components/Game.vue @@ -13,18 +13,18 @@