Spaces:
Sleeping
Sleeping
Commit
·
df4bec6
1
Parent(s):
49798bd
fix: sync board shape when joining existing room
Browse filesWhen joining an existing room, now properly syncs:
- Board shape from server's gameState
- Game moves from TGN
- Viewport rendering with correct board
Co-Authored-By: Claude <noreply@anthropic.com>
trigo-web/app/dist/assets/{index-BMzK2esc.js → index--_hEjmsI.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
trigo-web/app/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>Trigo - 3D Go Game</title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/index
|
| 9 |
<link rel="stylesheet" crossorigin href="/assets/index-Siwlapuk.css">
|
| 10 |
</head>
|
| 11 |
<body>
|
|
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>Trigo - 3D Go Game</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/index--_hEjmsI.js"></script>
|
| 9 |
<link rel="stylesheet" crossorigin href="/assets/index-Siwlapuk.css">
|
| 10 |
</head>
|
| 11 |
<body>
|
trigo-web/app/src/views/TrigoView.vue
CHANGED
|
@@ -1266,6 +1266,47 @@
|
|
| 1266 |
playerStore.joinRoom(response.roomId, response.playerColor);
|
| 1267 |
console.log(`[TrigoView] Room joined: ${response.roomId}`);
|
| 1268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1269 |
// Extract opponent from players list
|
| 1270 |
if (response.players && socketApi.socket.id) {
|
| 1271 |
for (const [playerId, player] of Object.entries(response.players) as [string, any][]) {
|
|
|
|
| 1266 |
playerStore.joinRoom(response.roomId, response.playerColor);
|
| 1267 |
console.log(`[TrigoView] Room joined: ${response.roomId}`);
|
| 1268 |
|
| 1269 |
+
// Sync game state from server (board shape, moves, etc.)
|
| 1270 |
+
if (response.gameState) {
|
| 1271 |
+
const gs = response.gameState;
|
| 1272 |
+
console.log(`[TrigoView] Syncing game state:`, gs);
|
| 1273 |
+
|
| 1274 |
+
// Get board shape from server
|
| 1275 |
+
const serverBoardShape = gs.boardShape || boardShape.value;
|
| 1276 |
+
|
| 1277 |
+
// Try to load from TGN, fall back to initializeGame
|
| 1278 |
+
let loaded = false;
|
| 1279 |
+
if (gs.tgn) {
|
| 1280 |
+
loaded = gameStore.loadFromTGN(gs.tgn);
|
| 1281 |
+
}
|
| 1282 |
+
|
| 1283 |
+
if (!loaded) {
|
| 1284 |
+
gameStore.initializeGame(serverBoardShape);
|
| 1285 |
+
if (gs.gameStatus === "playing") {
|
| 1286 |
+
gameStore.startGame();
|
| 1287 |
+
}
|
| 1288 |
+
}
|
| 1289 |
+
|
| 1290 |
+
// Update viewport with server's board shape
|
| 1291 |
+
if (viewport) {
|
| 1292 |
+
viewport.setBoardShape(serverBoardShape);
|
| 1293 |
+
viewport.clearBoard();
|
| 1294 |
+
|
| 1295 |
+
// Re-render all stones from game state
|
| 1296 |
+
const stones = gameStore.getAllStones();
|
| 1297 |
+
for (const stone of stones) {
|
| 1298 |
+
viewport.addStone(stone.x, stone.y, stone.z, stone.color);
|
| 1299 |
+
}
|
| 1300 |
+
|
| 1301 |
+
if (gs.gameStatus === "playing") {
|
| 1302 |
+
viewport.setGameActive(true);
|
| 1303 |
+
}
|
| 1304 |
+
}
|
| 1305 |
+
|
| 1306 |
+
// Update board shape dropdown
|
| 1307 |
+
selectedBoardShape.value = printBoardShape(serverBoardShape);
|
| 1308 |
+
}
|
| 1309 |
+
|
| 1310 |
// Extract opponent from players list
|
| 1311 |
if (response.players && socketApi.socket.id) {
|
| 1312 |
for (const [playerId, player] of Object.entries(response.players) as [string, any][]) {
|