fix : focus active player automatically on game load
This commit is contained in:
+13
-5
@@ -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"
|
||||
>
|
||||
</GamePlayerListElement>
|
||||
|
||||
Reference in New Issue
Block a user