`, // 5. public/style.css 'public/style.css': `* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: #fff; min-height: 100vh; padding: 20px; } .container { max-width: 1200px; margin: 0 auto; } header { text-align: center; margin-bottom: 30px; padding: 20px; background: rgba(255, 255, 255, 0.05); border-radius: 15px; backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); } h1 { color: #4cc9f0; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 10px; } .game-info { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding: 15px; background: rgba(0, 0, 0, 0.3); border-radius: 10px; } #gameStatus { font-size: 18px; color: #72efdd; } #multiplierDisplay { font-size: 36px; font-weight: bold; color: #00ff88; text-shadow: 0 0 10px rgba(0, 255, 136, 0.5); transition: all 0.1s; } .main-content { display: grid; gap: 30px; } .game-area { background: rgba(255, 255, 255, 0.05); border-radius: 15px; padding: 20px; border: 1px solid rgba(255, 255, 255, 0.1); } .multiplier-graph { position: relative; margin-bottom: 20px; } #gameCanvas { width: 100%; height: 400px; background: rgba(0, 0, 0, 0.3); border-radius: 10px; display: block; } .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; } .bet-section, .player-info { background: rgba(0, 0, 0, 0.3); padding: 20px; border-radius: 10px; } .bet-amount { display: flex; gap: 10px; margin: 15px 0; } input { padding: 10px 15px; border: none; border-radius: 5px; background: rgba(255, 255, 255, 0.1); color: white; font-size: 16px; } input:focus { outline: 2px solid #4cc9f0; } .btn-amount { padding: 10px 20px; background: #4361ee; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background 0.3s; } .btn-amount:hover { background: #3a56d4; } .auto-cashout { display: flex; align-items: center; gap: 10px; margin: 15px 0; } .btn-bet, .btn-cashout { width: 100%; padding: 15px; margin: 10px 0; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: all 0.3s; } .btn-bet { background: linear-gradient(135deg, #00b4d8, #0077b6); color: white; } .btn-bet:hover:not(:disabled) { background: linear-gradient(135deg, #0096c7, #005885); } .btn-cashout { background: linear-gradient(135deg, #4cc9f0, #4361ee); color: white; } .btn-cashout:hover:not(:disabled) { background: linear-gradient(135deg, #3ab8df, #3250d4); } .btn-bet:disabled, .btn-cashout:disabled { opacity: 0.5; cursor: not-allowed; } .player-info { max-height: 300px; overflow-y: auto; } .provably-fair-section { background: rgba(255, 255, 255, 0.05); border-radius: 15px; padding: 25px; border: 1px solid rgba(255, 255, 255, 0.1); } .seed-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin: 20px 0; } .seed-group { background: rgba(0, 0, 0, 0.3); padding: 20px; border-radius: 10px; } .seed-input { display: flex; gap: 10px; margin: 10px 0; } .btn-small { padding: 8px 15px; background: #7209b7; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background 0.3s; } .btn-small:hover { background: #5a088f; } .seed-hash { font-family: monospace; background: rgba(0, 0, 0, 0.5); padding: 15px; border-radius: 5px; word-break: break-all; margin: 10px 0; color: #9d4edd; } .note { font-size: 14px; color: #aaa; margin-top: 10px; } .verification { margin-top: 30px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.1); } .verify-inputs { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; margin: 15px 0; } .btn-verify { padding: 10px 20px; background: #38b000; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background 0.3s; } .btn-verify:hover { background: #2d8c00; } #verificationResult { padding: 15px; background: rgba(0, 0, 0, 0.3); border-radius: 5px; margin-top: 10px; min-height: 60px; } .game-history { background: rgba(255, 255, 255, 0.05); border-radius: 15px; padding: 25px; border: 1px solid rgba(255, 255, 255, 0.1); } table { width: 100%; border-collapse: collapse; margin-top: 15px; } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.1); } th { background: rgba(0, 0, 0, 0.3); color: #4cc9f0; } tr:hover { background: rgba(255, 255, 255, 0.05); } .crash-point { color: #ff006e; font-weight: bold; } .btn-verify-small { padding: 5px 10px; background: #7209b7; color: white; border: none; border-radius: 3px; cursor: pointer; font-size: 12px; } .btn-verify-small:hover { background: #5a088f; } @media (max-width: 768px) { .controls, .seed-controls { grid-template-columns: 1fr; } .verify-inputs { grid-template-columns: 1fr; } } @keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }`, // 6. public/client.js 'public/client.js': `class CrashGameClient { constructor() { this.socket = io(); this.gameState = { isRunning: false, currentMultiplier: 1.0, myBet: null, clientSeed: 'BxRsop3XGXHKKENQgX8X', nextServerSeedHash: '', history: [] }; this.canvas = document.getElementById('gameCanvas'); this.ctx = this.canvas.getContext('2d'); this.graphPoints = []; this.animationId = null; this.init(); } init() { // DOM Elements this.multiplierDisplay = document.getElementById('multiplierDisplay'); this.gameStatus = document.getElementById('gameStatus'); this.betAmount = document.getElementById('betAmount'); this.autoCashout = document.getElementById('autoCashout'); this.placeBetBtn = document.getElementById('placeBet'); this.cashoutBtn = document.getElementById('cashoutBtn'); this.clientSeedInput = document.getElementById('clientSeed'); this.serverSeedHash = document.getElementById('serverSeedHash'); this.verifyBtn = document.getElementById('verifyBtn'); this.historyBody = document.getElementById('historyBody'); this.playerBets = document.getElementById('playerBets'); // Event Listeners this.setupEventListeners(); // Socket Events this.setupSocketEvents(); // Start animation loop this.animate(); } setupEventListeners() { // Bet amount buttons document.querySelectorAll('.btn-amount').forEach(btn => { btn.addEventListener('click', (e) => { this.betAmount.value = e.target.dataset.amount; }); }); // Place bet this.placeBetBtn.addEventListener('click', () => { const amount = parseFloat(this.betAmount.value); const autoCashout = parseFloat(this.autoCashout.value); if (amount > 0 && autoCashout >= 1.1) { this.socket.emit('placeBet', { amount, autoCashout }); this.gameState.myBet = { amount, autoCashout, cashedOut: false }; this.updatePlayerBets(); } }); // Cashout this.cashoutBtn.addEventListener('click', () => { this.socket.emit('cashout'); if (this.gameState.myBet) { this.gameState.myBet.cashedOut = true; } this.cashoutBtn.disabled = true; }); // Generate random client seed document.getElementById('generateClientSeed').addEventListener('click', () => { const randomSeed = this.generateRandomSeed(); this.clientSeedInput.value = randomSeed; this.gameState.clientSeed = randomSeed; }); // Change client seed document.getElementById('changeSeed').addEventListener('click', () => { const newSeed = this.clientSeedInput.value.trim(); if (newSeed) { this.gameState.clientSeed = newSeed; this.socket.emit('changeClientSeed', newSeed); } }); // Verify game this.verifyBtn.addEventListener('click', () => { this.verifyGame(); }); } setupSocketEvents() { // Game state update this.socket.on('gameState', (state) => { this.gameState.isRunning = state.isRunning; this.gameState.nextServerSeedHash = state.nextServerSeedHash; this.gameState.history = state.history; this.serverSeedHash.textContent = state.nextServerSeedHash; this.updateHistoryTable(); }); // Game start this.socket.on('gameStart', (data) => { this.gameState.isRunning = true; this.gameState.currentMultiplier = 1.0; this.graphPoints = []; this.gameState.myBet = null; this.gameStatus.textContent = 'Game in progress...'; this.gameStatus.style.color = '#72efdd'; this.placeBetBtn.disabled = true; this.cashoutBtn.disabled = false; // Reset multiplier display this.multiplierDisplay.textContent = '1.00x'; this.multiplierDisplay.style.color = '#00ff88'; this.updatePlayerBets(); }); // Multiplier update this.socket.on('multiplierUpdate', (data) => { if (!this.gameState.isRunning) return; this.gameState.currentMultiplier = parseFloat(data.multiplier); this.multiplierDisplay.textContent = \`\${parseFloat(data.multiplier).toFixed(2)}x\`; // Add point to graph this.graphPoints.push(parseFloat(data.multiplier)); // Color change based on multiplier if (this.gameState.currentMultiplier > 10) { this.multiplierDisplay.style.color = '#ff006e'; } else if (this.gameState.currentMultiplier > 5) { this.multiplierDisplay.style.color = '#ffbe0b'; } // Check auto-cashout if (this.gameState.myBet && !this.gameState.myBet.cashedOut && this.gameState.currentMultiplier >= this.gameState.myBet.autoCashout) { this.cashoutBtn.disabled = true; } }); // Game end this.socket.on('gameEnd', (data) => { this.gameState.isRunning = false; this.gameStatus.textContent = \`Game crashed at \${data.crashPoint}x\`; this.gameStatus.style.color = '#ff006e'; this.placeBetBtn.disabled = false; this.cashoutBtn.disabled = true; // Add to history this.addToHistory({ id: data.gameId, crashPoint: data.crashPoint, serverSeed: data.serverSeed }); // Reset after 5 seconds setTimeout(() => { if (!this.gameState.isRunning) { this.gameStatus.textContent = 'Next game starting soon...'; this.gameStatus.style.color = '#72efdd'; } }, 5000); }); // Bet accepted this.socket.on('betAccepted', (data) => { this.showNotification(\`Bet placed: $\${data.amount} (Auto: \${data.autoCashout}x)\`); }); // Cashout success this.socket.on('cashoutSuccess', (data) => { this.showNotification(\`💰 Cashed out at \${data.multiplier}x! Won: $\${data.winnings}\`); if (this.gameState.myBet) { this.gameState.myBet.cashedOut = true; this.gameState.myBet.cashoutMultiplier = data.multiplier; } this.updatePlayerBets(); }); // Auto cashout this.socket.on('autoCashout', (data) => { this.showNotification(\`⚡ Auto-cashout at \${data.multiplier}x! Won: $\${data.winnings}\`); if (this.gameState.myBet) { this.gameState.myBet.cashedOut = true; this.gameState.myBet.cashoutMultiplier = data.multiplier; } this.updatePlayerBets(); }); // New server seed hash this.socket.on('newServerSeedHash', (data) => { this.gameState.nextServerSeedHash = data.nextServerSeedHash; this.serverSeedHash.textContent = data.nextServerSeedHash; }); // Client seed changed this.socket.on('clientSeedChanged', (data) => { this.showNotification(data.message); }); } generateRandomSeed() { return Array.from(crypto.getRandomValues(new Uint8Array(16))) .map(b => b.toString(16).padStart(2, '0')) .join(''); } updatePlayerBets() { if (!this.gameState.myBet) { this.playerBets.innerHTML = '

No active bets

'; return; } const bet = this.gameState.myBet; let html = \`

Amount: $\${bet.amount}

Auto Cashout: \${bet.autoCashout}x

Status: \${bet.cashedOut ? \`Cashed out at \${bet.cashoutMultiplier}x\` : 'Active'}

\`; if (bet.cashedOut && bet.cashoutMultiplier) { const winnings = (bet.amount * bet.cashoutMultiplier).toFixed(2); html += \`

Winnings: $\${winnings}

\`; } html += '
'; this.playerBets.innerHTML = html; } updateHistoryTable() { this.historyBody.innerHTML = ''; this.gameState.history.forEach(game => { const row = document.createElement('tr'); const time = new Date(game.timestamp).toLocaleTimeString(); row.innerHTML = \` \${game.id.substring(0, 8)}... \${parseFloat(game.crashPoint).toFixed(2)}x \${game.players} \${time} \`; this.historyBody.appendChild(row); }); // Add event listeners to verify buttons document.querySelectorAll('.btn-verify-small').forEach(btn => { btn.addEventListener('click', (e) => { const gameId = e.target.dataset.gameid; const game = this.gameState.history.find(g => g.id === gameId); if (game) { document.getElementById('verifyGameId').value = gameId; document.getElementById('verifyServerSeed').value = game.serverSeed; } }); }); } addToHistory(game) { const time = new Date().toLocaleTimeString(); const row = document.createElement('tr'); row.innerHTML = \` \${game.id.substring(0, 8)}... \${game.crashPoint}x - \${time} \`; this.historyBody.insertBefore(row, this.historyBody.firstChild); // Keep only last 10 rows while (this.historyBody.children.length > 10) { this.historyBody.removeChild(this.historyBody.lastChild); } } verifyGame() { const gameId = document.getElementById('verifyGameId').value; const clientSeed = document.getElementById('verifyClientSeed').value; const serverSeed = document.getElementById('verifyServerSeed').value; if (!gameId || !clientSeed || !serverSeed) { this.showVerificationResult('Please fill all fields', false); return; } fetch(\`/api/verify/\${gameId}/\${clientSeed}/\${serverSeed}\`) .then(res => res.json()) .then(data => { if (data.verified) { this.showVerificationResult(\` ✅ Game Verified!
Expected Crash Point: \${data.expectedCrashPoint}x
Server Seed Hash: \${data.serverSeedHash.substring(0, 16)}...
\${data.message} \`, true); } else { this.showVerificationResult(\`❌ Verification failed: \${data.error}\`, false); } }) .catch(err => { this.showVerificationResult(\`❌ Error: \${err.message}\`, false); }); } showVerificationResult(message, isSuccess) { const resultDiv = document.getElementById('verificationResult'); resultDiv.style.color = isSuccess ? '#00ff88' : '#ff006e'; resultDiv.innerHTML = message; } showNotification(message) { const notification = document.createElement('div'); notification.style.cssText = \` position: fixed; top: 20px; right: 20px; background: rgba(0, 0, 0, 0.8); color: white; padding: 15px 20px; border-radius: 5px; z-index: 1000; border-left: 4px solid #4cc9f0; animation: slideIn 0.3s ease; \`; notification.textContent = message; document.body.appendChild(notification); setTimeout(() => { notification.style.animation = 'slideOut 0.3s ease'; setTimeout(() => { document.body.removeChild(notification); }, 300); }, 3000); } animate() { this.animationId = requestAnimationFrame(() => this.animate()); // Clear canvas this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); // Draw graph background this.ctx.fillStyle = 'rgba(0, 0, 0, 0.3)'; this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); // Draw grid this.ctx.strokeStyle = 'rgba(255, 255, 255, 0.1)'; this.ctx.lineWidth = 1; // Horizontal lines (multiplier) for (let i = 1; i <= 10; i++) { const y = this.canvas.height - (i / 10) * this.canvas.height; this.ctx.beginPath(); this.ctx.moveTo(0, y); this.ctx.lineTo(this.canvas.width, y); this.ctx.stroke(); // Label this.ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; this.ctx.font = '12px Arial'; this.ctx.fillText(\`\${i}x\`, 10, y - 5); } // Draw graph line if (this.graphPoints.length > 1) { this.ctx.beginPath(); this.ctx.moveTo(0, this.canvas.height); const maxMultiplier = Math.max(10, ...this.graphPoints); const xStep = this.canvas.width / 100; const startIndex = Math.max(0, this.graphPoints.length - 100); const pointsToDraw = this.graphPoints.slice(startIndex); pointsToDraw.forEach((multiplier, index) => { const x = index * xStep; const y = this.canvas.height - (multiplier / maxMultiplier) * this.canvas.height; if (index === 0) { this.ctx.moveTo(x, y); } else { this.ctx.lineTo(x, y); } }); // Gradient for line const gradient = this.ctx.createLinearGradient(0, 0, this.canvas.width, 0); gradient.addColorStop(0, '#00ff88'); gradient.addColorStop(1, '#ff006e'); this.ctx.strokeStyle = gradient; this.ctx.lineWidth = 3; this.ctx.stroke(); // Draw current multiplier indicator if (this.gameState.isRunning && this.graphPoints.length > 0) { const currentMultiplier = this.graphPoints[this.graphPoints.length - 1]; const y = this.canvas.height - (currentMultiplier / maxMultiplier) * this.canvas.height; const x = Math.min(pointsToDraw.length * xStep, this.canvas.width); // Circle at current point this.ctx.beginPath(); this.ctx.arc(x, y, 8, 0, Math.PI * 2); this.ctx.fillStyle = '#ff006e'; this.ctx.fill(); this.ctx.strokeStyle = 'white'; this.ctx.lineWidth = 2; this.ctx.stroke(); // Text this.ctx.fillStyle = 'white'; this.ctx.font = 'bold 16px Arial'; this.ctx.fillText(\`\${currentMultiplier.toFixed(2)}x\`, x + 15, y - 10); } } } } // Start the game when page loads window.addEventListener('DOMContentLoaded', () => { new CrashGameClient(); });`, // 7. README.md 'README.md': `# Provably Fair Crash Game (Aviator Style) A complete, ready-to-run crash game implementation with provable fairness. ## Features ✅ **Provably Fair System** - Server seed + client seed generate random crash points - SHA256 hashing for verification - Players can verify any past game ✅ **Aviator-style Gameplay** - Real-time multiplier increase - Auto-cashout feature - Live graph animation - Bet placement and cashout ✅ **Complete Verification System** - View server seed hash before game - Verify game results after completion - Game history with verification buttons ✅ **Modern UI** - Responsive design - Real-time updates via WebSocket - Animated multiplier display - Professional styling ## Installation 1. **Extract the ZIP file** 2. **Install dependencies:** \`\`\`bash npm install \`\`\` 3. **Start the server:** \`\`\`bash npm start # or for development with auto-restart: npm run dev \`\`\` 4. **Open in browser:** \`\`\` http://localhost:3000 \`\`\` ## How to Play 1. **Set your client seed** (or generate random) 2. **Place a bet** with amount and auto-cashout multiplier 3. **Watch the multiplier increase** in real-time 4. **Cash out** before the game crashes or use auto-cashout 5. **Verify game results** using the verification system ## Provably Fair System The game uses a provably fair algorithm: 1. **Before game:** Server shows hash of next server seed 2. **During game:** Crash point generated from: - Server seed (revealed after game) - Client seed (chosen by player) - Game nonce 3. **After game:** Players can verify using seeds ## File Structure \`\`\` crash-game/ ├── package.json # Dependencies ├── server.js # Main server ├── game-logic.js # Provably fair algorithm ├── public/ │ ├── index.html # Frontend UI │ ├── style.css # Styling │ └── client.js # Frontend logic └── README.md # This file \`\`\` ## API Endpoints - \`GET /\` - Main game interface - \`GET /api/verify/:gameId/:clientSeed/:serverSeed\` - Verify game result - \`WebSocket /\` - Real-time game updates ## Dependencies - **express** - HTTP server - **socket.io** - Real-time WebSocket communication - **crypto** - Node.js crypto library (built-in) ## Customization You can modify: - **Game speed**: Adjust multiplier calculation in \`server.js\` - **House edge**: Change in \`game-logic.js\` - **UI styling**: Modify \`public/style.css\` - **Maximum multiplier**: Adjust in \`game-logic.js\` ## Security Notes ⚠️ **For Production Use:** 1. Add user authentication 2. Implement proper database (MySQL, MongoDB) 3. Add rate limiting 4. Use HTTPS 5. Implement proper session management 6. Add input validation and sanitization 7. Consider using a framework like Express.js with security middleware ## License This project is for educational purposes. Modify and use as needed. ## Support For issues or questions, check the code comments or consult Node.js/socket.io documentation.`, // 8. .gitignore '.gitignore': `node_modules/ .env *.log .DS_Store .vscode/`, // 9. Setup Script (optional) 'setup.bat': `@echo off echo Installing Aviator Crash Game... echo. if not exist node_modules ( echo Installing dependencies... npm install echo Dependencies installed successfully! ) else ( echo Dependencies already installed. ) echo. echo To start the game, run: echo npm start echo. echo Then open: http://localhost:3000 echo. pause`, // 10. setup.sh 'setup.sh': `#!/bin/bash echo "Installing Aviator Crash Game..." echo "" if [ ! -d "node_modules" ]; then echo "Installing dependencies..." npm install echo "Dependencies installed successfully!" else echo "Dependencies already installed." fi echo "" echo "To start the game, run:" echo "npm start" echo "" echo "Then open: http://localhost:3000" echo ""` }; // Create ZIP file const zip = new JSZip(); // Create folder structure const publicFolder = zip.folder("public"); // Add files to ZIP for (const [filename, content] of Object.entries(files)) { if (filename.startsWith('public/')) { const publicFilename = filename.replace('public/', ''); publicFolder.file(publicFilename, content); } else { zip.file(filename, content); } } // Generate ZIP file zip.generateAsync({type: "blob"}) .then(function(content) { // Create download link const link = document.createElement("a"); link.href = URL.createObjectURL(content); link.download = "aviator-crash-game.zip"; document.body.appendChild(link); link.click(); document.body.removeChild(link); // Update status document.getElementById("downloadStatus").innerHTML = '
✅ Download complete! File: aviator-crash-game.zip
'; }); } // Load JSZip library function loadJSZip() { const script = document.createElement('script'); script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js'; script.onload = function() { document.getElementById("downloadBtn").disabled = false; document.getElementById("downloadBtn").innerHTML = '📦 Download ZIP File'; }; document.head.appendChild(script); } window.onload = loadJSZip;

🚀 Aviator Crash Game - Complete Package

Provably fair crash game with Node.js backend + HTML/CSS/JS frontend

Download Complete Game Package

Includes all files needed to run your own crash game server

📦 What's Included:

aviator-crash-game.zip/
├── package.json
├── server.js
├── game-logic.js
├── README.md
├── .gitignore
├── setup.bat
├── setup.sh
└── public/
    ├── index.html
    ├── style.css
    └── client.js

🔒 Provably Fair

SHA256 hashing with server + client seeds. Players can verify every game.

🎮 Aviator Gameplay

Real-time multiplier growth, auto-cashout, and smooth animations.

⚡ Real-time

WebSocket-based updates for instant gameplay without page reloads.

📱 Responsive UI

Modern design that works on desktop and mobile devices.

🚀 Quick Start Guide:

  1. Download the ZIP file using the button above
  2. Extract the files to a folder
  3. Install dependencies: npm install
  4. Start the server: npm start
  5. Open browser to: http://localhost:3000

🛠️ Technical Requirements: