/** * This script block contains generic helper function usable across casino games: * - Wagers * - Feed * - Leaderboard */ function initializeGame() { updateFeed(); updateLeaderboard(); } function updatePlayerCurrencies(updated) { if (updated.coins) { document.getElementById("user-coins-amount").textContent = updated.coins; document.getElementById("user-coins-amount-mobile").textContent = updated.coins; document.getElementById("user-coins-amount-casino").textContent = updated.coins; } if (updated.marseybux) { document.getElementById("user-bux-amount").textContent = updated.marseybux; document.getElementById("user-bux-amount-mobile").textContent = updated.marseybux; document.getElementById("user-bux-amount-casino").textContent = updated.marseybux; } } function getWager() { const amount = document.getElementById("wagerAmount").value; const currency = document.querySelector( 'input[name="wagerCurrency"]:checked' ).value; const genericCurrency = currency == 'marseybux' ? 'marseybux' : 'coins'; return { amount, currency: genericCurrency, localCurrency: currency }; } function disableWager() { document.getElementById("wagerAmount").disabled = true; document.getElementById("wagerCoins").classList.add('disabled'); document.getElementById("wagerMarseybux").classList.add('disabled'); } function enableWager() { document.getElementById("wagerAmount").disabled = false; document.getElementById("wagerCoins").classList.remove('disabled'); document.getElementById("wagerMarseybux").classList.remove('disabled'); } function updateResult(text, className) { clearResult(); const result = document.getElementById("casinoGameResult"); result.style.visibility = "visible"; result.textContent = text; result.classList.add(`alert-${className}`); } function clearResult() { const result = document.getElementById("casinoGameResult"); result.style.visibility = "hidden"; result.textContent = "N/A"; result.classList.remove("alert-success", "alert-danger", "alert-warning"); } function updateFeed(newFeed) { let feed; if (newFeed) { feed = newFeed; } else { const gameFeed = document.getElementById("casinoGameFeed"); feed = gameFeed.dataset.feed; feed = JSON.parse(feed); gameFeed.dataset.feed = ""; } const feedHtml = feed .map( (entry) => `