File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -58,10 +58,14 @@ const handleConnect = () => {
5858 socket .value .on (' connect' , () => {
5959 console .log (' socket connected' )
6060 joinGame ()
61- // handleJoinGame()
61+ getGameStatus ().then (() => {
62+ console .log (' getGameStatus' )
63+ if (! gameStore .me ? .joined ){
64+ handleJoinGame ()
65+ }
66+ })
6267 // 因為panel已經加入過玩家 這裡再加一次會失敗
6368 // 須考慮之後從大平台加入時要如何加入game
64- getGameStatus ()
6569 // socket.value.emit({ player_id: 'Leave3310' })
6670 })
6771 socket .value .on (' game_update' , (data ) => {
@@ -132,13 +136,13 @@ const getGameStatus = async () => {
132136 })
133137 gameStore .setGameStatus (res .data )
134138}
135- // const handleJoinGame = async () => {
136- // const gameRoomID = route.query.gameRoomID
137- // const playerId = route.query.playerId || playerId.value
138- // await api.put(`/player/${ playerId }/join`, {
139- // gameRoomID,
140- // })
141- // }
139+ const handleJoinGame = async () => {
140+ const gameRoomID = route .params . gameId
141+ // const playerId = playerId.value
142+ await api .put (` /player/${ playerId . value } /join` , {
143+ gameRoomID,
144+ })
145+ }
142146watch (
143147 () => gameStore .gameStatus .current_player ,
144148 (newVal , oldVal ) => {
Original file line number Diff line number Diff line change @@ -208,6 +208,9 @@ export const useGameStore = defineStore('useGameStore', () => {
208208 return true
209209 }
210210 } )
211+ const me = computed ( ( ) => {
212+ return gameStatus . value . players . find ( ( player ) => player . player_id === playingId . value )
213+ } )
211214 return {
212215 gameStatus,
213216 roundStart,
@@ -245,5 +248,6 @@ export const useGameStore = defineStore('useGameStore', () => {
245248 selectSecretEnded,
246249 spellFailed,
247250 setSpellFailed,
251+ me,
248252 }
249253} )
You can’t perform that action at this time.
0 commit comments