File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,18 +74,20 @@ const useHandler = () => {
7474 } ;
7575
7676 const handleStartGame = async ( invitationCode : InvitationCode , players : Players ) => {
77- const gameDocRef = ref ( db , 'games/' + invitationCode ) ;
78- await runTransaction ( gameDocRef , ( currentData : GameData ) => {
79- if ( ! currentData ) {
80- const newGame = createNewGame ( invitationCode , players ) ;
81- return newGame ;
82- }
83- } ) ;
84- const roomDocRef = ref ( db , 'rooms/' + invitationCode ) ;
85- await runTransaction ( roomDocRef , ( currentData : RoomData ) => {
86- if ( ! currentData ) return undefined ;
87- return null ;
88- } ) ;
77+ try {
78+ const gameDocRef = ref ( db , 'games/' + invitationCode ) ;
79+ await runTransaction ( gameDocRef , ( currentData : GameData ) => {
80+ if ( currentData ) return ;
81+ return createNewGame ( invitationCode , players ) ;
82+ } ) ;
83+
84+ const roomDocRef = ref ( db , 'rooms/' + invitationCode ) ;
85+ await update ( roomDocRef , { status : 'playing' } ) ;
86+
87+ } catch ( error ) {
88+ console . error ( "게임을 시작하는 중 오류가 발생했습니다:" , error ) ;
89+ alert ( "오류가 발생하여 게임을 시작할 수 없습니다." ) ;
90+ }
8991 } ;
9092
9193 const handleAccuse = async (
You can’t perform that action at this time.
0 commit comments