diff --git a/apps/web/src/pages/RoomPage.tsx b/apps/web/src/pages/RoomPage.tsx index f4aa55c..d639281 100644 --- a/apps/web/src/pages/RoomPage.tsx +++ b/apps/web/src/pages/RoomPage.tsx @@ -91,6 +91,9 @@ function Room({ code, me }: { code: string; me: PublicUser }) { const [ui, setUi] = useState(null); const [leaveAsk, setLeaveAsk] = useState(false); const [chatOpen, setChatOpen] = useState(false); + // [한 판 더] takes me back to this room's lobby after game N (kept per tab so a reload stays there). + const lobbyKey = `bg:lobby:${code}`; + const [lobbyAfter, setLobbyAfter] = useState(() => Number(sessionStorage.getItem(lobbyKey)) || null); const gameId = room?.gameId; useEffect(() => { @@ -144,7 +147,15 @@ function Room({ code, me }: { code: string; me: PublicUser }) { } const g = { nameKo: gameName(room.gameId) }; - const inGame = room.status === 'playing' || room.status === 'paused' || (room.status === 'finished' && !!game); + const backInLobby = room.status === 'finished' && lobbyAfter === room.gameNo; + const inGame = room.status === 'playing' || room.status === 'paused' || (room.status === 'finished' && !!game && !backInLobby); + const toLobby = () => { + sessionStorage.setItem(lobbyKey, String(room.gameNo)); + setLobbyAfter(room.gameNo); + // Seated people come back ready, so the host sees who wants another game. + const seat = room.seats.find((s) => s?.user.id === me.id); + if (seat && room.hostId !== me.id && !seat.ready) socket.send({ t: 'ready', ready: true }); + }; // Games with their own chat channels (마피아) close the room chat while playing (the server refuses it too). const roomChatClosed = !!ui.ownChat && (room.status === 'playing' || room.status === 'paused'); const doLeave = () => { @@ -225,7 +236,7 @@ function Room({ code, me }: { code: string; me: PublicUser }) { ) : ( )} - {room.status === 'finished' && result && game && } + {room.status === 'finished' && result && game && !backInLobby && } {chatOpen && !roomChatClosed && ( setChatOpen(false)} label="채팅"> @@ -628,15 +639,12 @@ function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui ); } -function ResultPanel({ room, me, players, onLeave }: { room: RoomView; me: PublicUser; players: Record; onLeave: () => void }) { +function ResultPanel({ room, me, players, onLeave, onAgain }: { room: RoomView; me: PublicUser; players: Record; onLeave: () => void; onAgain: () => void }) { const result = useRoom((s) => s.result)!; const [hidden, setHidden] = useState(false); const played = useRef(false); const seatedAll = room.seats.filter(Boolean).map((s) => s!.user.id); - const amSeated = seatedAll.includes(me.id); - // Computer players always agree to a rematch. const seated = seatedAll.filter((u) => !isBotId(u)); - const voted = room.rematchVotes.includes(me.id); // Solo games (e.g. 요트 다이스) have one ranked player: neither a draw nor a win. const solo = result.ranking.flat().length === 1; const allFirst = !solo && result.ranking.length === 1; @@ -678,11 +686,10 @@ function ResultPanel({ room, me, players, onLeave }: { room: RoomView; me: Publi )), )} - {amSeated && ( - - )} + {/* Back to this room's lobby: seats, computers and settings can change before the host starts again. */} + {/* One primary action (한 판 더); the rest share one quieter row. */}