-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch5.js
More file actions
25 lines (23 loc) · 1.01 KB
/
Copy pathpatch5.js
File metadata and controls
25 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const fs = require('fs');
const file = '/Users/uday/uno-real/frontend/src/hooks/useSocket.ts';
let content = fs.readFileSync(file, 'utf8');
const targetStr = `if (payload.lastAction && !isInitialLoad) {`;
const insertStr = `
// Sync non-card states immediately to prevent "It is not your turn" desync
// This ensures the UI instantly hides "YOUR TURN" and prevents double-plays
useGameStore.setState({
currentPlayerId: payload.currentPlayerId,
currentPlayerSeat: payload.currentPlayerSeat,
direction: payload.direction,
wildColor: payload.wildColor,
gameStatus: payload.gameStatus,
colorChooserId: payload.colorChooserId,
winnerId: payload.winnerId,
winnerName: payload.winnerName,
unoCalled: payload.unoCalled
});
`;
if (content.includes(targetStr) && !content.includes('Sync non-card states immediately')) {
content = content.replace(targetStr, targetStr + insertStr);
fs.writeFileSync(file, content);
}