const spinReels = async (isTurbo = false) => {…
- User
const spinReels = async (isTurbo = false) => { console.log("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
if (spinningRef.current) return; spinningRef.current = true; // Hide the payline total win container during the spin // if (paylineTotalWinContainer) { paylineTotalWinContainer.visible = false; // Hides the win text container paylineWinContainer.removeChildren() textContainerBet.removeChildren() paylineTotalWinContainer.removeChildren(); // } keepShowingRef.current = false; // 🔁 Stop payline cycling textContainerBet.text = "GOOD LUCK!"; paylineWinContainer.visible = false; if (winTextRef.current && winTextRef.current.length) { const app = appRef.current?.app; if (app) { winTextRef.current.forEach(child => { if (child.parent) { child.parent.removeChild(child); } if (child.destroy) { child.destroy(); } }); } winTextRef.current = []; } // Clear previous GIFs gifSpritesRef.current.forEach(({ gif, original, parent }) => { if (gif && gif.parent) { gif.parent.removeChild(gif); // ✅ safe cleanup } if (original && parent && !original.parent) { parent.addChild(original); // ✅ restore original sprite } }); gifSpritesRef.current = []; // console.log(turboMode, isTurbo); const spinSpeed = turboMode ? 50 : 30; let stopDelays; let column0ScrollY = 0; // Tracks how much col 0 has scrolled let turboScrollTriggered = false; // When to start columns 1-4 const baseHeight = (itemHeight + spacingY); const reelHeights = isTurbo ? Math.max(baseHeight * 3, baseHeight * 2.5) : baseHeight * 3; const obj = { amount: betAmount.text, sessionId: sessionStorage.getItem('sessionId-Baklaha'), }; // console.log("⚡⚡⚡ ~ spinReels ~ obj:", obj) let matrix let paylines let totalwin try { const response = await betSpin.mutateAsync(obj); matrix = response?.gameResult?.matrix; userBal = response?.newBalance; paylines = response?.gameResult?.paylines totalwin = response?.win // console.log("⚡⚡⚡ ~ spinReels ~ paylines:", paylines) updateCreditsDisplay(); } catch (err) { console.error("Error during betSpin.mutateAsync:", err); } if (!matrix) { console.error("Invalid matrix from API:", matrix); // isSpinning = false; return; } const newColumns = Array(5).fill().map(() => Array(3).fill().map(() => Math.floor(Math.random() * items.length)) ); const ticker = app.ticker; const doubleColumnContainers = columnContainers.map((originalContainer, index) => { const current = new Container(); const next = new Container(); //while spinning const setup = (container, data) => { container.removeChildren(); for (let row = 0; row < 3; row++) { const itemIndex = data[row]; const itemX = 150; const itemY = row * (itemHeight + spacingY); // Add background rectangle const background = Sprite.from(rectangleback); background.x = itemX; background.y = itemY; background.width = itemWidth - 20; background.height = itemHeight - 35; background.zIndex = 10 container.addChild(background); // Add symbol sprite const sprite = Sprite.from(items[itemIndex]); const symbolMarginX = 1; const symbolMarginY = 2; sprite.x = itemX + symbolMarginX - 5; sprite.y = itemY + symbolMarginY - 10; sprite.width = itemWidth - symbolMarginX - 15;; sprite.height = itemHeight - symbolMarginY - 20; sprite.zIndex = 11; container.addChild(sprite); } }; setup(current, columns[index]); const columnData = [ matrix[0][index], matrix[1][index], matrix[2][index], ]; setup(next, columnData); current.y = 0; next.y = reelHeights; const container = new Container(); container.x = startX + index * (itemWidth + spacingX) - 80; container.y = startY - 3; container.addChild(current); container.addChild(next); gridContainer.addChild(container); // Add new container inside masked gridContainer gridContainer.removeChild(originalContainer); // Remove old container from masked gridContainer originalContainer.destroy({ children: true }); columnContainers[index] = container; return { container, current, next, index, stopped: false }; }); if (turboMode) { stopDelays = doubleColumnContainers.map((_, index) => 20 + index * 5); } else { stopDelays = doubleColumnContainers.map((_, index) => 60 + index * 15); } // const stopDelays = doubleColumnContainers.map((_, index) => 60 + index * 15); let frame = 0; // Pre-scroll config const preScrollOffset = 40; const preScrollFrames = 10; const preScrollDelayPerCol = 5; // frames to delay each column's movement let preScrollCounter = 0; ticker.add(function preScroll() { let allDone = true; doubleColumnContainers.forEach(({ current, next, index }) => { const delayFrames = index * preScrollDelayPerCol; // Start scrolling only after its delay has passed if (preScrollCounter >= delayFrames && preScrollCounter < delayFrames + preScrollFrames) { const offsetPerFrame = preScrollOffset / preScrollFrames; current.y -= offsetPerFrame; next.y -= offsetPerFrame; allDone = false; } else if (preScrollCounter < delayFrames + preScrollFrames) { allDone = false; // Still waiting for some columns to finish } }); preScrollCounter++; if (allDone) { ticker.remove(preScroll); // startInitialSpin(); ticker.add(scroll); // Begin actual spin } }); function createFinalContainer(index, matrix, items, rectangleback, scatter, globalScatterState) { const container = new Container(); let scatterPlaced = false; for (let row = 0; row < 3; row++) { let itemIndex = matrix[row][index]; const itemX = 150; const itemY = row * (itemHeight + spacingY) + 36; const background = Sprite.from(rectangleback); background.x = itemX; background.y = itemY; background.width = itemWidth - 20; background.height = itemHeight - 35; background.zIndex = 10; container.addChild(background); const sprite = Sprite.from(items[itemIndex]); sprite.x = itemX - 4; sprite.y = itemY - 8; sprite.width = itemWidth - 10; sprite.height = itemHeight - 30; sprite.zIndex = 11; sprite._itemId = itemIndex; container.addChild(sprite); if (!doubleColumnContainers[index].finalSprites) doubleColumnContainers[index].finalSprites = []; doubleColumnContainers[index].finalSprites[row] = sprite; } return container; } let globalScatterState = { count: 0 }; const scroll = function () { frame++; doubleColumnContainers.forEach((col, index) => { if (col.stopped) return; let currentSpeed = spinSpeed; if (isTurbo) { doubleColumnContainers.forEach((col, index) => { if (col.stopped) return; const speed = spinSpeed; if (index === 0) { // Column 0 scrolls continuously col.current.y += speed; col.next.y += speed; column0ScrollY += speed; if (col.current.y >= reelHeights) { col.current.y = col.next.y - reelHeights; } if (col.next.y >= reelHeights) { col.next.y = col.current.y - reelHeights; } if (column0ScrollY >= reelHeights && !turboScrollTriggered) { turboScrollTriggered = true; } } else if (turboScrollTriggered) { // Columns 1-4 scroll only once col.scrollY = (col.scrollY || 0) + speed; col.current.y += speed; col.next.y += speed; if (col.scrollY >= reelHeights) { const finalContainer = createFinalContainer(index, matrix, items, rectangleback, scatter, globalScatterState); col.container.removeChildren(); col.container.addChild(finalContainer); col.stopped = true; } } }); // Stop column 0 and finish when all stopped if (doubleColumnContainers.every((col, i) => col.stopped || i === 0)) { const col = doubleColumnContainers[0]; col.container.removeChildren(); const finalContainer = createFinalContainer(0, matrix, items, rectangleback, scatter, globalScatterState); col.container.addChild(finalContainer); col.stopped = true; // Finalize spin ticker.remove(scroll); setColumns(matrix); // checkForMatches(matrix, doubleColumnContainers, items.indexOf(scatter)); // spinningRef.current = false; textContainerBet.text = ""; // checkForMatches(newColumns, doubleColumnContainers, items.indexOf(scatter)); if (loadButtonRef.current) { loadButtonRef.current.interactive = true; loadButtonRef.current.buttonMode = true; loadButtonRef.current.alpha = 1; loadButtonRef.current.cursor = 'pointer'; } } } else { // Normal mode: all columns spin until delay col.current.y += currentSpeed; col.next.y += currentSpeed; if (col.current.y >= reelHeights) { col.current.y = col.next.y - reelHeights; } if (col.next.y >= reelHeights) { col.next.y = col.current.y - reelHeights; } if (frame >= stopDelays[index]) { const finalContainer = createFinalContainer(index, matrix, items, rectangleback, scatter, globalScatterState); col.container.removeChildren(); col.container.addChild(finalContainer); col.stopped = true; } } }); if (doubleColumnContainers.every(col => col.stopped)) { ticker.remove(scroll); // console.log("⚡⚡⚡ ~ scroll ~ matrix:", matrix) setColumns(matrix); if (totalwin > 0) { paylineWinContainer.text = ""; paylineWinContainer.visible = false; checkForMatches(matrix, doubleColumnContainers, paylines, totalwin, spinningRef); textContainerBet.text = ""; updateLastWinDisplay(totalwin, lastWinAmount); // spinningRef.current = false; } else { textContainerBet.text = "PLACE YOUR BETS"; paylineWinContainer.visible = false; updateLastWinDisplay(lastWin, lastWinAmount); paylineWinContainer.text = ""; spinningRef.current = false; } // Finalize spin // spinningRef.current = false; if (loadButtonRef.current) { loadButtonRef.current.interactive = true; loadButtonRef.current.buttonMode = true; loadButtonRef.current.alpha = 1; loadButtonRef.current.cursor = 'pointer'; } } } }; in the above code after spin completed each column arranged stopped one by one where the functionality is implemented - Assistant
- User
console.log("⚡⚡⚡ ~ scroll ~ frame >= stopDelays[index]:", frame >= stopDelays[index],index) if (frame >= stopDelays[index]) { const finalContainer = createFinalContainer(index, matrix, items, rectangleback, scatter, globalScatterState); col.container.removeChildren(); col.container.addChild(finalContainer); col.stopped = true; }
column 1,2,3,4,5 when stoping need to find - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.