From 14c4a434f78270b7eaa5b59201ce48751e7705b6 Mon Sep 17 00:00:00 2001 From: Moritz Ruth Date: Sun, 23 Apr 2023 14:24:24 +0200 Subject: [PATCH] commit #5 --- package.json | 2 ++ src/clientGame.ts | 11 +++++--- src/components/Game.vue | 49 +++++++++++++++++++--------------- src/components/LoginScreen.vue | 5 ++-- src/server/game.ts | 1 + src/trpc.ts | 2 +- 6 files changed, 42 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 12cc769..a45a6a4 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "1.0.0", "type": "module", "scripts": { + "start:ui": "vite preview --host", + "build:ui": "vite build", "dev:ui": "vite", "dev:server": "NODE_ENV=development tsx watch --clear-screen=false ./src/server/main.ts" }, diff --git a/src/clientGame.ts b/src/clientGame.ts index 6c903a5..62a3c30 100644 --- a/src/clientGame.ts +++ b/src/clientGame.ts @@ -25,7 +25,6 @@ export const useGame = defineStore("game", () => { const actions = reactive([]) const auth = useAuth() - const actionsBus = useGameActionsBus() actionsBus.on(action => { actions.push(action) @@ -60,11 +59,15 @@ export const useGame = defineStore("game", () => { }) }) }, - async create() { - return await trpcClient.createGame.mutate() + async reset() { + window.location.hash = "" + lobbyCode.value = null + state.value = getUninitializedGameState() + actions.splice(0, actions.length) }, start: () => trpcClient.game.start.mutate({ lobbyCode: lobbyCode.value! }), hit: () => trpcClient.game.hit.mutate({ lobbyCode: lobbyCode.value! }), - stay: () => trpcClient.game.stay.mutate({ lobbyCode: lobbyCode.value! }) + stay: () => trpcClient.game.stay.mutate({ lobbyCode: lobbyCode.value! }), + create: () => trpcClient.createGame.mutate() } }) \ No newline at end of file diff --git a/src/components/Game.vue b/src/components/Game.vue index 9567b05..4ff6ee5 100644 --- a/src/components/Game.vue +++ b/src/components/Game.vue @@ -1,27 +1,34 @@