Spaces:
Sleeping
Sleeping
Commit
·
e367b4e
1
Parent(s):
a7d41bc
feat(debug): add window.trigoApi for testing
Browse files
trigo-web/app/dist/assets/{index-CMsE5CnF.js → index-Cs_21k17.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-Cs_21k17.js"></script>
|
| 9 |
<link rel="stylesheet" crossorigin href="/assets/index-Siwlapuk.css">
|
| 10 |
</head>
|
| 11 |
<body>
|
trigo-web/app/src/views/TrigoView.vue
CHANGED
|
@@ -1692,6 +1692,125 @@
|
|
| 1692 |
|
| 1693 |
// Add keyboard shortcuts
|
| 1694 |
window.addEventListener("keydown", handleKeyPress);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1695 |
});
|
| 1696 |
|
| 1697 |
// Watch for game mode changes and initialize modes as needed
|
|
|
|
| 1692 |
|
| 1693 |
// Add keyboard shortcuts
|
| 1694 |
window.addEventListener("keydown", handleKeyPress);
|
| 1695 |
+
|
| 1696 |
+
// Expose testing API to window for debugging/testing
|
| 1697 |
+
(window as any).trigoApi = {
|
| 1698 |
+
// Get current game state
|
| 1699 |
+
getState: () => ({
|
| 1700 |
+
gameMode: gameMode.value,
|
| 1701 |
+
roomId: playerStore.roomId,
|
| 1702 |
+
playerColor: playerStore.playerColor,
|
| 1703 |
+
connectionStatus: playerStore.connectionStatus,
|
| 1704 |
+
currentPlayer: currentPlayer.value,
|
| 1705 |
+
moveCount: moveHistory.value.length,
|
| 1706 |
+
boardShape: boardShape.value,
|
| 1707 |
+
isConnected: socketApi.socket.connected
|
| 1708 |
+
}),
|
| 1709 |
+
|
| 1710 |
+
// Reset game without confirmation dialog (for VS People mode)
|
| 1711 |
+
resetGame: (boardShapeStr?: string) => {
|
| 1712 |
+
const shape = boardShapeStr
|
| 1713 |
+
? parseBoardShape(boardShapeStr)
|
| 1714 |
+
: parseBoardShape(selectedBoardShape.value);
|
| 1715 |
+
|
| 1716 |
+
if (gameMode.value === "vs-people") {
|
| 1717 |
+
return new Promise((resolve) => {
|
| 1718 |
+
socketApi.socket.emit("resetGame", {
|
| 1719 |
+
boardShape: shape,
|
| 1720 |
+
swapColors: false
|
| 1721 |
+
}, (response: any) => {
|
| 1722 |
+
if (response.success) {
|
| 1723 |
+
console.log("[trigoApi] Game reset successfully");
|
| 1724 |
+
resolve({ success: true });
|
| 1725 |
+
} else {
|
| 1726 |
+
console.error("[trigoApi] Reset failed:", response.error);
|
| 1727 |
+
resolve({ success: false, error: response.error });
|
| 1728 |
+
}
|
| 1729 |
+
});
|
| 1730 |
+
});
|
| 1731 |
+
} else {
|
| 1732 |
+
// Single player mode
|
| 1733 |
+
gameStore.initializeGame(shape);
|
| 1734 |
+
gameStore.startGame();
|
| 1735 |
+
if (viewport) {
|
| 1736 |
+
viewport.setBoardShape(shape);
|
| 1737 |
+
viewport.clearBoard();
|
| 1738 |
+
viewport.setGameActive(true);
|
| 1739 |
+
}
|
| 1740 |
+
return Promise.resolve({ success: true });
|
| 1741 |
+
}
|
| 1742 |
+
},
|
| 1743 |
+
|
| 1744 |
+
// Make a move at position
|
| 1745 |
+
makeMove: (x: number, y: number, z: number) => {
|
| 1746 |
+
if (gameMode.value === "vs-people") {
|
| 1747 |
+
return new Promise((resolve) => {
|
| 1748 |
+
socketApi.makeMove(x, y, z, (response: any) => {
|
| 1749 |
+
resolve(response);
|
| 1750 |
+
});
|
| 1751 |
+
});
|
| 1752 |
+
} else {
|
| 1753 |
+
const result = gameStore.makeMove(x, y, z);
|
| 1754 |
+
if (result.success && viewport) {
|
| 1755 |
+
viewport.addStone(x, y, z, gameStore.opponentPlayer);
|
| 1756 |
+
}
|
| 1757 |
+
return Promise.resolve(result);
|
| 1758 |
+
}
|
| 1759 |
+
},
|
| 1760 |
+
|
| 1761 |
+
// Pass turn
|
| 1762 |
+
pass: () => {
|
| 1763 |
+
if (gameMode.value === "vs-people") {
|
| 1764 |
+
socketApi.pass();
|
| 1765 |
+
return Promise.resolve({ success: true });
|
| 1766 |
+
} else {
|
| 1767 |
+
const success = gameStore.pass();
|
| 1768 |
+
return Promise.resolve({ success });
|
| 1769 |
+
}
|
| 1770 |
+
},
|
| 1771 |
+
|
| 1772 |
+
// Fetch room list
|
| 1773 |
+
fetchRoomList: () => {
|
| 1774 |
+
return new Promise((resolve) => {
|
| 1775 |
+
socketApi.listRooms((response: any) => {
|
| 1776 |
+
resolve(response);
|
| 1777 |
+
});
|
| 1778 |
+
});
|
| 1779 |
+
},
|
| 1780 |
+
|
| 1781 |
+
// Join a room
|
| 1782 |
+
joinRoom: (roomId: string) => {
|
| 1783 |
+
return new Promise((resolve) => {
|
| 1784 |
+
socketApi.joinRoom(roomId, playerStore.nickname, preferredColor.value, (response: any) => {
|
| 1785 |
+
if (response.success) {
|
| 1786 |
+
playerStore.setRoomId(roomId);
|
| 1787 |
+
playerStore.connectionStatus = "connected";
|
| 1788 |
+
}
|
| 1789 |
+
resolve(response);
|
| 1790 |
+
});
|
| 1791 |
+
});
|
| 1792 |
+
},
|
| 1793 |
+
|
| 1794 |
+
// Create new room
|
| 1795 |
+
createRoom: () => {
|
| 1796 |
+
return new Promise((resolve) => {
|
| 1797 |
+
socketApi.createRoom(playerStore.nickname, preferredColor.value, (response: any) => {
|
| 1798 |
+
if (response.success && response.roomId) {
|
| 1799 |
+
playerStore.setRoomId(response.roomId);
|
| 1800 |
+
playerStore.connectionStatus = "connected";
|
| 1801 |
+
}
|
| 1802 |
+
resolve(response);
|
| 1803 |
+
});
|
| 1804 |
+
});
|
| 1805 |
+
},
|
| 1806 |
+
|
| 1807 |
+
// Set board shape
|
| 1808 |
+
setBoardShape: (shapeStr: string) => {
|
| 1809 |
+
selectedBoardShape.value = shapeStr;
|
| 1810 |
+
return { success: true, shape: shapeStr };
|
| 1811 |
+
}
|
| 1812 |
+
};
|
| 1813 |
+
console.log("[TrigoView] Testing API exposed at window.trigoApi");
|
| 1814 |
});
|
| 1815 |
|
| 1816 |
// Watch for game mode changes and initialize modes as needed
|