diff --git a/src/game/solitaire.js b/src/game/solitaire.js index 3d37409..e5adeef 100644 --- a/src/game/solitaire.js +++ b/src/game/solitaire.js @@ -1,5 +1,6 @@ // --- Constants for Deck Creation --- import {sleep} from "openai/core"; +import {emitSolitaireUpdate, emitUpdate} from "../server/socket.js"; const SUITS = ['h', 'd', 's', 'c']; // Hearts, Diamonds, Spades, Clubs const RANKS = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']; @@ -353,10 +354,11 @@ export async function autoSolveMoves(gameState) { sourcePileType: 'tableauPiles', userId: gameState.userId, } - moveCard(gameState, moveData); + moveCard(gameState, moveData) + emitSolitaireUpdate(gameState.userId, moveData); moved = true; await sleep(500); // Pause for visualization - //TODO: maybe needs an emit here to update clients? + } } } while (moved)//(foundations.reduce((acc, pile) => acc + pile.length, 0)); diff --git a/src/server/socket.js b/src/server/socket.js index c5fa0db..6343535 100644 --- a/src/server/socket.js +++ b/src/server/socket.js @@ -344,4 +344,6 @@ export async function emitPokerToast(data) { } export const emitUpdate = (type, room) => io.emit("blackjack:update", { type, room }); -export const emitToast = (payload) => io.emit("blackjack:toast", payload); \ No newline at end of file +export const emitToast = (payload) => io.emit("blackjack:toast", payload); + +export const emitSolitaireUpdate = (userId, moveData) => io.emit('solitaire:update', {userId, moveData}); \ No newline at end of file