File size: 2,764 Bytes
4916856
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18a5d47
 
 
 
 
 
 
 
4916856
 
 
 
 
 
 
 
 
 
18a5d47
 
4916856
 
 
 
 
 
 
18a5d47
 
 
 
 
 
 
 
 
4916856
 
 
 
18a5d47
 
 
 
4916856
 
 
 
18a5d47
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Emoji Slot Machine</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
        }
        #slot-machine {
            display: inline-flex;
            justify-content: center;
            align-items: center;
            border: 3px solid #ccc;
            padding: 20px;
            border-radius: 10px;
            font-size: 2rem;
        }
        .slot {
            padding: 0 10px;
        }
        button {
            font-size: 1rem;
            padding: 10px 20px;
            margin-top: 20px;
        }
        #balance {
            font-size: 1.25rem;
            margin-top: 10px;
        }
        #history {
            font-size: 1rem;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <h1>Emoji Slot Machine</h1>
    <div id="slot-machine">
        <div class="slot" id="slot1">🍌</div>
        <div class="slot" id="slot2">🍌</div>
        <div class="slot" id="slot3">🍌</div>
    </div>
    <button id="spin-btn">Spin</button>
    <div id="balance">Balance: $<span id="balance-amount">10.00</span></div>
    <div id="history"></div>

    <script>
        document.getElementById('spin-btn').addEventListener('click', function () {
            var emojis = ['🍎', '🍌', 'πŸ’', 'πŸ‡', 'πŸ‰'];
            var slot1 = document.getElementById('slot1');
            var slot2 = document.getElementById('slot2');
            var slot3 = document.getElementById('slot3');
            var balanceAmount = document.getElementById('balance-amount');
            var history = document.getElementById('history');
            // Deduct 25 cents
            var newBalance = parseFloat(balanceAmount.textContent) - 0.25;
            if (newBalance < 0) {
                alert("Insufficient balance.");
                return;
            }
            balanceAmount.textContent = newBalance.toFixed(2);
            slot1.textContent = emojis[Math.floor(Math.random() * emojis.length)];
            slot2.textContent = emojis[Math.floor(Math.random() * emojis.length)];
            slot3.textContent = emojis[Math.floor(Math.random() * emojis.length)];
            if (slot1.textContent === slot2.textContent && slot2.textContent === slot3.textContent) {
                var winAmount = Math.floor(Math.random() * 100) + 1;
                newBalance = parseFloat(balanceAmount.textContent) + winAmount;
                balanceAmount.textContent = newBalance.toFixed(2);
                history.innerHTML += '<p>You won $' + winAmount + '! πŸŽ‰</p>';
            }
        });
    </script>
</body>
</html>