let balance = 1000;
let timeLeft = 30;
let currentBet = null;
let periodNumber = 202603310001;
function updateTimer() {
const timerEl = document.getElementById(‘countdown’);
const periodEl = document.getElementById(‘period-id’);
let interval = setInterval(() => {
timeLeft--;
timerEl.innerText = timeLeft;
if (timeLeft <= 0) {
generateResult();
timeLeft = 30;
periodNumber++;
periodEl.innerText = periodNumber;
}
}, 1000);
}
function placeBet(type) {
currentBet = type;
document.getElementById(‘bet-status’).innerText = You selected: ${type};
}
function generateResult() {
const num = Math.floor(Math.random() * 10); // 0-9
const size = num >= 5 ? ‘BIG’ : ‘SMALL’;
const color = (num % 2 === 0) ? ‘
’ : ‘
’;
// Win/Loss Logic
if (currentBet) {
if (currentBet === size) {
balance += 10;
alert(`WIN! Result was ${num} (${size})`);
} else {
balance -= 10;
alert(`LOSS! Result was ${num} (${size})`);
}
document.getElementById('balance').innerText = balance;
currentBet = null;
document.getElementById('bet-status').innerText = "Place your guess!";
}
// Add to Table
const table = document.getElementById('history-body');
const row = `<tr><td>${periodNumber}</td><td>${num}</td><td>${size}</td><td>${color}</td></tr>`;
table.insertAdjacentHTML('afterbegin', row);
}
updateTimer();