From 23784cb3bcc879a2a7bc604317b821e7f0d329b9 Mon Sep 17 00:00:00 2001 From: HamdiHarahap Date: Fri, 2 Aug 2024 16:01:26 +0700 Subject: [PATCH] commit --- assets/js/main.js | 50 +++++++++++++++++++++++++++++++++++++++++++---- index.html | 8 ++++---- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 937734a..ecf66db 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -41,7 +41,6 @@ const spin = document.querySelector('.spin') spin.addEventListener('click', function () { if (saldo < 1000) { alert('Saldo tidak cukup untuk bermain!') - return } saldo -= 1000 @@ -54,7 +53,7 @@ spin.addEventListener('click', function () { setTimeout(function () { if (firstIndex === secondIndex && secondIndex === thirdIndex) { alert('Selamat, kamu menang!') - saldo += 15000 + saldo += 10000 updateSaldo() } }, 300) @@ -65,7 +64,6 @@ const autoSpin = document.querySelector('.auto') autoSpin.addEventListener('click', function () { if (saldo < 1000) { alert('Saldo tidak cukup untuk bermain!') - return } const interval = setInterval(function () { @@ -89,7 +87,7 @@ autoSpin.addEventListener('click', function () { secondIndex === thirdIndex ) { alert('Selamat, kamu menang!') - saldo += 15000 + saldo += 10000 updateSaldo() } }, 300) @@ -101,3 +99,47 @@ autoSpin.addEventListener('click', function () { clearInterval(interval) }) }) + +const tenSpin = document.querySelector('.tenSpin') + +tenSpin.addEventListener('click', function () { + let spinCount = 0 + + const interval = setInterval(function () { + if (saldo < 1000) { + clearInterval(interval) + alert('Saldo tidak cukup untuk bermain!') + return + } + + saldo -= 1000 + updateSaldo() + + const firstIndex = spinImage(firstImage) + const secondIndex = spinImage(secondImage) + const thirdIndex = spinImage(thirdImage) + + setTimeout(function () { + if ( + saldo >= 0 && + firstIndex === secondIndex && + secondIndex === thirdIndex + ) { + alert('Selamat, kamu menang!') + saldo += 10000 + updateSaldo() + } + }, 300) + + spinCount++ + if (spinCount >= 10) { + clearInterval(interval) + } + }, 1200) + + const stopSpin = document.querySelector('.stop') + + stopSpin.addEventListener('click', function () { + clearInterval(interval) + }) +}) diff --git a/index.html b/index.html index c0202f2..23e8cea 100644 --- a/index.html +++ b/index.html @@ -22,10 +22,10 @@

Saldo anda sekarang sebesar : 0

Auto Spin

Stop Spin

-

Spin 10x

-

Spin 20x

-

Spin 50x

-

Spin 100x

+

Spin 10x

+

Spin 20x

+

Spin 50x

+

Spin 100x