mirror of
https://github.com/milk-net/milk-net.github.io.git
synced 2025-04-19 17:43:42 -05:00
Update script.js
This commit is contained in:
parent
ac6bbadd89
commit
2e26475bdd
1 changed files with 86 additions and 148 deletions
|
@ -81,8 +81,54 @@ function updateStats(game, amount, xp) {
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blackjack functions (same as before, keeping for integration)...
|
// Slots Game
|
||||||
// Slots function (keep as before)...
|
function playSlots() {
|
||||||
|
const bet = parseInt(document.getElementById('slots-bet').value);
|
||||||
|
let money = parseInt(localStorage.getItem('casino-money'));
|
||||||
|
|
||||||
|
if (!bet || bet <= 0 || bet > money) {
|
||||||
|
alert('Invalid bet amount.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
money -= bet;
|
||||||
|
localStorage.setItem('casino-money', money);
|
||||||
|
|
||||||
|
const symbols = ['🍒', '🍋', '🔔', '💎', '7️⃣'];
|
||||||
|
const reels = document.querySelectorAll('#slots-reels .reel');
|
||||||
|
|
||||||
|
reels.forEach(reel => {
|
||||||
|
const result = symbols[Math.floor(Math.random() * symbols.length)];
|
||||||
|
const span = reel.querySelector('span');
|
||||||
|
span.style.animation = 'none';
|
||||||
|
span.offsetHeight;
|
||||||
|
span.textContent = result;
|
||||||
|
span.style.animation = '';
|
||||||
|
span.style.animation = 'spinReel 0.5s ease-out';
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const results = Array.from(reels).map(reel => reel.querySelector('span').textContent);
|
||||||
|
const [a, b, c] = results;
|
||||||
|
|
||||||
|
let winnings = 0;
|
||||||
|
let xp = 0;
|
||||||
|
let message = 'You lost.';
|
||||||
|
|
||||||
|
if (a === b && b === c) {
|
||||||
|
winnings = bet * 5;
|
||||||
|
xp = 15;
|
||||||
|
message = `Jackpot! ${a} ${b} ${c} — You won $${winnings}!`;
|
||||||
|
} else if (a === b || b === c || a === c) {
|
||||||
|
winnings = bet * 2;
|
||||||
|
xp = 5;
|
||||||
|
message = `Nice! You matched two and won $${winnings}!`;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('slots-message').innerText = message;
|
||||||
|
updateStats('slots', winnings, xp);
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
// Roulette Game
|
// Roulette Game
|
||||||
function playRoulette() {
|
function playRoulette() {
|
||||||
|
@ -98,112 +144,28 @@ function playRoulette() {
|
||||||
money -= bet;
|
money -= bet;
|
||||||
localStorage.setItem('casino-money', money);
|
localStorage.setItem('casino-money', money);
|
||||||
|
|
||||||
const outcome = Math.floor(Math.random() * 37);
|
const wheel = document.getElementById('roulette-animation');
|
||||||
let color = outcome === 0 ? 'green' : outcome % 2 === 0 ? 'black' : 'red';
|
wheel.style.animation = 'none';
|
||||||
|
wheel.offsetHeight;
|
||||||
|
wheel.style.animation = 'spinRoulette 1s ease-out';
|
||||||
|
|
||||||
let resultText = `The ball landed on ${outcome} (${color}). You lost.`;
|
setTimeout(() => {
|
||||||
let winnings = 0;
|
const outcome = Math.floor(Math.random() * 37);
|
||||||
let xp = 0;
|
const color = outcome === 0 ? 'green' : outcome % 2 === 0 ? 'black' : 'red';
|
||||||
|
|
||||||
if (color === choice) {
|
let resultText = `The ball landed on ${outcome} (${color}). You lost.`;
|
||||||
winnings = choice === 'green' ? bet * 14 : bet * 2;
|
let winnings = 0;
|
||||||
resultText = `The ball landed on ${outcome} (${color}). You won $${winnings}!`;
|
let xp = 0;
|
||||||
xp = choice === 'green' ? 20 : 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('roulette-result').innerText = resultText;
|
if (color === choice) {
|
||||||
updateStats('roulette', winnings, xp);
|
winnings = choice === 'green' ? bet * 14 : bet * 2;
|
||||||
}
|
resultText = `The ball landed on ${outcome} (${color}). You won $${winnings}!`;
|
||||||
|
xp = choice === 'green' ? 20 : 10;
|
||||||
|
}
|
||||||
|
|
||||||
// Horse Betting Game
|
document.getElementById('roulette-result').innerText = resultText;
|
||||||
function playHorse() {
|
updateStats('roulette', winnings, xp);
|
||||||
const bet = parseInt(document.getElementById('horse-bet').value);
|
}, 1000);
|
||||||
const choice = parseInt(document.getElementById('horse-choice').value);
|
|
||||||
let money = parseInt(localStorage.getItem('casino-money'));
|
|
||||||
|
|
||||||
if (!bet || bet <= 0 || bet > money) {
|
|
||||||
alert('Invalid bet amount.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
money -= bet;
|
|
||||||
localStorage.setItem('casino-money', money);
|
|
||||||
|
|
||||||
const winningHorse = Math.ceil(Math.random() * 3);
|
|
||||||
let resultText = `Horse ${winningHorse} won. You lost.`;
|
|
||||||
let winnings = 0;
|
|
||||||
let xp = 0;
|
|
||||||
|
|
||||||
if (choice === winningHorse) {
|
|
||||||
winnings = bet * 3;
|
|
||||||
resultText = `Horse ${winningHorse} won. You won $${winnings}!`;
|
|
||||||
xp = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('horse-result').innerText = resultText;
|
|
||||||
updateStats('horse', winnings, xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Casino War Game
|
|
||||||
function playWar() {
|
|
||||||
const bet = parseInt(document.getElementById('war-bet').value);
|
|
||||||
let money = parseInt(localStorage.getItem('casino-money'));
|
|
||||||
|
|
||||||
if (!bet || bet <= 0 || bet > money) {
|
|
||||||
alert('Invalid bet amount.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
money -= bet;
|
|
||||||
localStorage.setItem('casino-money', money);
|
|
||||||
|
|
||||||
const playerCard = Math.ceil(Math.random() * 13);
|
|
||||||
const dealerCard = Math.ceil(Math.random() * 13);
|
|
||||||
|
|
||||||
let resultText = `You drew ${playerCard}, dealer drew ${dealerCard}. You lost.`;
|
|
||||||
let winnings = 0;
|
|
||||||
let xp = 0;
|
|
||||||
|
|
||||||
if (playerCard > dealerCard) {
|
|
||||||
winnings = bet * 2;
|
|
||||||
resultText = `You drew ${playerCard}, dealer drew ${dealerCard}. You won $${winnings}!`;
|
|
||||||
xp = 10;
|
|
||||||
} else if (playerCard === dealerCard) {
|
|
||||||
winnings = bet;
|
|
||||||
resultText = `It's a tie! Your bet is returned.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('war-result').innerText = resultText;
|
|
||||||
updateStats('war', winnings, xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Coin Flip Game
|
|
||||||
function playCoinflip() {
|
|
||||||
const bet = parseInt(document.getElementById('coinflip-bet').value);
|
|
||||||
const choice = document.getElementById('coinflip-choice').value;
|
|
||||||
let money = parseInt(localStorage.getItem('casino-money'));
|
|
||||||
|
|
||||||
if (!bet || bet <= 0 || bet > money) {
|
|
||||||
alert('Invalid bet amount.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
money -= bet;
|
|
||||||
localStorage.setItem('casino-money', money);
|
|
||||||
|
|
||||||
const flip = Math.random() < 0.5 ? 'heads' : 'tails';
|
|
||||||
let resultText = `It landed on ${flip}. You lost.`;
|
|
||||||
let winnings = 0;
|
|
||||||
let xp = 0;
|
|
||||||
|
|
||||||
if (choice === flip) {
|
|
||||||
winnings = bet * 2;
|
|
||||||
resultText = `It landed on ${flip}. You won $${winnings}!`;
|
|
||||||
xp = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('coinflip-result').innerText = resultText;
|
|
||||||
updateStats('coinflip', winnings, xp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crash Game
|
// Crash Game
|
||||||
|
@ -219,55 +181,31 @@ function playCrash() {
|
||||||
money -= bet;
|
money -= bet;
|
||||||
localStorage.setItem('casino-money', money);
|
localStorage.setItem('casino-money', money);
|
||||||
|
|
||||||
const multiplier = (Math.random() * 5 + 1).toFixed(2);
|
const crashBar = document.getElementById('crash-animation');
|
||||||
const cashout = Math.random() * 5 + 1;
|
crashBar.style.transform = 'scaleX(0)';
|
||||||
|
crashBar.offsetHeight;
|
||||||
|
crashBar.style.transform = 'scaleX(1)';
|
||||||
|
|
||||||
let resultText = `Multiplier reached x${multiplier}. You lost.`;
|
setTimeout(() => {
|
||||||
let winnings = 0;
|
const multiplier = (Math.random() * 5 + 1).toFixed(2);
|
||||||
let xp = 0;
|
const cashout = Math.random() * 5 + 1;
|
||||||
|
|
||||||
if (cashout < multiplier) {
|
let resultText = `Multiplier reached x${multiplier}. You lost.`;
|
||||||
winnings = Math.floor(bet * cashout);
|
let winnings = 0;
|
||||||
resultText = `You cashed out at x${cashout.toFixed(2)} and won $${winnings}!`;
|
let xp = 0;
|
||||||
xp = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('crash-result').innerText = resultText;
|
if (cashout < multiplier) {
|
||||||
updateStats('crash', winnings, xp);
|
winnings = Math.floor(bet * cashout);
|
||||||
|
resultText = `You cashed out at x${cashout.toFixed(2)} and won $${winnings}!`;
|
||||||
|
xp = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('crash-result').innerText = resultText;
|
||||||
|
updateStats('crash', winnings, xp);
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keno Game
|
// (Other game functions stay as they are...)
|
||||||
function playKeno() {
|
|
||||||
const bet = parseInt(document.getElementById('keno-bet').value);
|
|
||||||
const picks = document.getElementById('keno-numbers').value.split(',').map(num => parseInt(num.trim())).filter(n => n >= 1 && n <= 10);
|
|
||||||
let money = parseInt(localStorage.getItem('casino-money'));
|
|
||||||
|
|
||||||
if (!bet || bet <= 0 || bet > money || picks.length === 0) {
|
|
||||||
alert('Invalid bet or picks. Pick numbers between 1-10.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
money -= bet;
|
|
||||||
localStorage.setItem('casino-money', money);
|
|
||||||
|
|
||||||
const draws = Array.from({ length: 3 }, () => Math.ceil(Math.random() * 10));
|
|
||||||
const matches = picks.filter(num => draws.includes(num)).length;
|
|
||||||
|
|
||||||
let resultText = `Drawn numbers: ${draws.join(', ')}. No matches.`;
|
|
||||||
let winnings = 0;
|
|
||||||
let xp = 0;
|
|
||||||
|
|
||||||
if (matches > 0) {
|
|
||||||
winnings = bet * matches * 2;
|
|
||||||
resultText = `Drawn numbers: ${draws.join(', ')}. You matched ${matches} numbers and won $${winnings}!`;
|
|
||||||
xp = matches * 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('keno-result').innerText = resultText;
|
|
||||||
updateStats('keno', winnings, xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
if (localStorage.getItem('casino-username')) {
|
if (localStorage.getItem('casino-username')) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue