From ad1739f7f43337182724ed79fd42c016f6646312 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:46:38 +0300 Subject: [PATCH] clean mines component --- .../lib/components/self/games/Mines.svelte | 194 ++++++------------ 1 file changed, 58 insertions(+), 136 deletions(-) diff --git a/website/src/lib/components/self/games/Mines.svelte b/website/src/lib/components/self/games/Mines.svelte index 5e3b9dc..41245e5 100644 --- a/website/src/lib/components/self/games/Mines.svelte +++ b/website/src/lib/components/self/games/Mines.svelte @@ -1,7 +1,7 @@ @@ -306,7 +238,6 @@ Mines Navigate through the minefield and cash out before hitting a mine! - @@ -325,20 +256,21 @@ handleTileClick(index)} disabled={!isPlaying} + class:revealed={revealedTiles.includes(index)} + class:mine={revealedTiles.includes(index) && + minePositions.includes(index) && + !clickedSafeTiles.includes(index)} + class:safe={revealedTiles.includes(index) && + !minePositions.includes(index) && + clickedSafeTiles.includes(index)} + class:light={document.documentElement.classList.contains('light')} + aria-label="Tile" > {#if revealedTiles.includes(index)} {#if minePositions.includes(index)} - + {:else} - - + - - Number of Mines + Number of Mines mineCount = Math.max(mineCount - 1, MIN_MINES)} + onclick={() => (mineCount = Math.max(mineCount - 1, MIN_MINES))} disabled={isPlaying || mineCount <= MIN_MINES} - aria-label="Decrease mines" - >- + aria-label="Decrease mines">- { + oninput={(e) => { const target = e.target as HTMLInputElement | null; const val = Math.max( MIN_MINES, @@ -385,30 +315,24 @@ mineCount = Math.min(mineCount + 1, 24)} + onclick={() => (mineCount = Math.min(mineCount + 1, 24))} disabled={isPlaying || mineCount >= 24} - aria-label="Increase mines" - >+ + aria-label="Increase mines">+ You will get - - {(calculateRawMultiplier( - isPlaying ? revealedTiles.length + 1 : 1, - mineCount - )).toFixed(2)}x + + {calculateRawMultiplier(isPlaying ? revealedTiles.length + 1 : 1, mineCount).toFixed( + 2 + )}x per tile, probability of winning: - - {calculateProbability( - isPlaying ? 1 : 1, - mineCount - )}% + + {calculateProbability(isPlaying ? 1 : 1, mineCount)}% - - Bet Amount - - setBetAmount(Math.floor(Math.min(balance, MAX_BET_AMOUNT)))} - disabled={isPlaying}>Max + disabled={isPlaying}>Max - - {#if !isPlaying} Start Game {:else} - {#if hasRevealedTile} - - + + Auto Cashout in {Math.ceil(AUTO_CASHOUT_TIME - autoCashoutTimer)}s - + = 7} style="width: {autoCashoutProgress}%" > - + {/if} @@ -493,7 +413,9 @@ Next Tile: - +{formatValue(betAmount * (calculateRawMultiplier(revealedTiles.length + 1, mineCount) - 1))} + +{formatValue( + betAmount * (calculateRawMultiplier(revealedTiles.length + 1, mineCount) - 1) + )} @@ -609,4 +531,4 @@ height: 32px; object-fit: contain; } - \ No newline at end of file +
You will get - - {(calculateRawMultiplier( - isPlaying ? revealedTiles.length + 1 : 1, - mineCount - )).toFixed(2)}x + + {calculateRawMultiplier(isPlaying ? revealedTiles.length + 1 : 1, mineCount).toFixed( + 2 + )}x per tile, probability of winning: - - {calculateProbability( - isPlaying ? 1 : 1, - mineCount - )}% + + {calculateProbability(isPlaying ? 1 : 1, mineCount)}%