Skip to content

Commit f084c13

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 44de31b + 87dcc74 commit f084c13

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

โ€Žsrc/pages/game-ready/GameReady.tsxโ€Ž

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ export default function GameReady() {
129129
}
130130
};
131131

132+
const handleTeamChange = (targetTeamName: string) => {
133+
console.log(`ํŒ€ ์ด๋™: ${targetTeamName}`);
134+
135+
let currentTeam = game?.teams.find((team) =>
136+
team.users.some((u) => u.nickname === user.nickname)
137+
);
138+
let currentTeamName = currentTeam?.teamName || null;
139+
140+
webSocketManager.moveTeamRequest(targetTeamName, currentTeamName || '');
141+
};
142+
132143
const handleGameStart = () => {
133144
console.log('๊ฒŒ์ž„ ์‹œ์ž‘ ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.');
134145
webSocketManager.startGameRequest();
@@ -222,6 +233,21 @@ export default function GameReady() {
222233
<div className="flex-1 text-center">{u.nickname}</div>
223234
</div>
224235
))}
236+
{/* ํŒ€ ์ด๋™ ๋ฒ„ํŠผ ํ‘œ์‹œ */}
237+
{!game?.teams.some(
238+
(t) =>
239+
t.users.some((u) => u.nickname === user.nickname) &&
240+
t.teamName === team.teamName
241+
) &&
242+
team.users.length < team.maxUserCount && (
243+
<div
244+
className="text-white flex rounded-lg border-2 border-dashed border-gray-500 cursor-pointer hover:border-orange-500 hover:bg-gray-800 transition duration-200"
245+
onClick={() => handleTeamChange(team.teamName)}
246+
>
247+
<div className="absolute self-center ml-2 text-xs">๐Ÿ”„</div>
248+
<div className="flex-1 text-center">ํŒ€ ์ด๋™</div>
249+
</div>
250+
)}
225251
</div>
226252
</div>
227253
))}

โ€Žsrc/services/WebSocketManager.tsโ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,21 @@ class WebSocketManager {
240240
}
241241
}
242242

243+
// ํŒ€ ์ด๋™
244+
moveTeamRequest(targetTeamName: string, currentTeamName: string) {
245+
const requestBody = {
246+
nickname: this.nickname,
247+
targetTeamName: targetTeamName,
248+
currentTeamName: currentTeamName,
249+
};
250+
251+
if (this.roomId) {
252+
this.sendMessage(`/app/room/${this.roomId}/move`, requestBody);
253+
} else {
254+
console.error('Room ID is not set');
255+
}
256+
}
257+
243258
// ์›น ์†Œ์ผ“ ์—ฐ๊ฒฐ ์ข…๋ฃŒ
244259
disconnect(): void {
245260
if (this.client) {

0 commit comments

Comments
ย (0)