diff --git a/pages/game.vue b/pages/game.vue index d6c812e..1a0c670 100644 --- a/pages/game.vue +++ b/pages/game.vue @@ -233,7 +233,13 @@ onBeforeMount(async () => { navigateTo("/lobby"); throw new Error("game not found"); } - focusedPlayer.value = selfPlayer.value ?? playerList.value![0]; + if (game.value.started) { + focusedPlayer.value = game.value.teams.find( + (t) => t._id == game.value?.currentTurn.currentTeam + )?.players[0]; + } else { + focusedPlayer.value = selfPlayer.value ?? playerList.value![0]; + } eventSource = subscribe(`/games/${gameId}/subscribe`); eventSource.addEventListener("message", async (message) => { @@ -264,10 +270,11 @@ const selfPlayer = computed(() => ); const isTurn = computed( () => - game.value && - selfPlayer.value && - game.value.teams.find((t) => t.players.includes(selfPlayer.value!))?._id == - game.value.currentTurn.currentTeam + (game.value && + selfPlayer.value && + game.value.teams.find((t) => t.players.includes(selfPlayer.value!)) + ?._id == game.value.currentTurn.currentTeam) ?? + false ); const turnChangeAnimationSpeed = computed( @@ -364,6 +371,7 @@ onUnmounted(() => { :game="game" @click="focusPlayer(p)" :focused="focusedPlayer == p" + :is-self-turn="isTurn" :self="selfPlayer == p" >