import React, { useState, useEffect, useRef, useMemo } from 'react'; import { Dice5, MessageSquare, Wallet, TrendingUp, History, Settings, ShieldCheck, ChevronDown, ChevronUp, Send, X, QrCode, ArrowRightLeft, Trophy, User, Zap } from 'lucide-react'; // --- Utils & Constants --- const HOUSE_EDGE = 0.005; // 0.5% const MAX_ROLL = 100.00; const generateRandomId = () => Math.random().toString(36).substr(2, 9); const generateHash = (seed) => "b10a8..." + seed.substr(0, 10) + "...f92"; // Mock hash for UI const NAMES = ["CryptoKing", "SatoshiNakamoto", "MoonBoi", "WhaleAlert", "LTC_Lover", "DiceMaster", "HODLer", "BearMarket", "BullRun"]; const MESSAGES = ["GL everyone!", "Just withdrew 50 LTC, easy.", "Rip my balance", "Need a lucky roll", "Anyone winning?", "To the moon! 🚀", "Nice streak!", "This site is legit."]; // --- Sub-Components --- // 1. Provably Fair Modal const ProvablyFairModal = ({ onClose, serverSeed, clientSeed, nonce }) => (

Provably Fair

{generateHash(serverSeed)}
{clientSeed}
{nonce}

The result is determined by combining the Server Seed, Client Seed, and Nonce. The Server Seed is hashed before you bet to prove we didn't change it.

); // 2. Wallet Modal const WalletModal = ({ onClose, type, balance, onAction }) => { const [amount, setAmount] = useState(''); const [step, setStep] = useState(type === 'deposit' ? 'qr' : 'input'); const [loading, setLoading] = useState(false); const handleAction = () => { setLoading(true); setTimeout(() => { onAction(parseFloat(amount) || 0); setLoading(false); onClose(); }, 1500); }; return (

{type} LTC

{type === 'deposit' && (

Send Litecoin (LTC) to the address below.
Your balance will update automatically.

Ltc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh
)} {type === 'withdraw' && (
setAmount(e.target.value)} placeholder="0.00000000" className="w-full bg-gray-900 border border-gray-700 rounded p-3 text-white focus:outline-none focus:border-blue-500" />
Available: {balance.toFixed(4)} LTC
)}
); }; // --- Main Application --- export default function LiteDice() { // State: User const [balance, setBalance] = useState(10.0000); // Start with 10 LTC const [netProfit, setNetProfit] = useState(0); const [level, setLevel] = useState(0); // State: Game const [betAmount, setBetAmount] = useState(0.1); const [target, setTarget] = useState(50.00); // Roll Under const [rollResult, setRollResult] = useState(null); const [isRolling, setIsRolling] = useState(false); const [gameHistory, setGameHistory] = useState([]); // State: UI const [activeTab, setActiveTab] = useState('all'); // all, highrollers, mine const [chatOpen, setChatOpen] = useState(true); const [modal, setModal] = useState(null); // 'deposit', 'withdraw', 'fair' const [seed, setSeed] = useState({ server: generateRandomId(), client: generateRandomId(), nonce: 0 }); // State: Data Feeds const [messages, setMessages] = useState([ { id: 1, user: 'System', text: 'Welcome to LiteDice! Provably Fair & Instant Withdrawals.', type: 'system' } ]); const [liveBets, setLiveBets] = useState([]); // --- Derived Values --- const winChance = target; const multiplier = (100 - HOUSE_EDGE * 100) / winChance; // Classic formula (99.5 / chance) const potentialProfit = (betAmount * multiplier) - betAmount; // --- Logic --- // Leveling Logic: 1 LTC profit = 1 Level useEffect(() => { const newLevel = Math.max(0, Math.floor(netProfit)); setLevel(newLevel); }, [netProfit]); // Simulation: Add fake live bets and chat messages useEffect(() => { const interval = setInterval(() => { // Add fake bet const isWin = Math.random() > 0.5; const fakeBet = { id: generateRandomId(), user: NAMES[Math.floor(Math.random() * NAMES.length)], bet: (Math.random() * 2).toFixed(2), multiplier: (1 + Math.random() * 3).toFixed(2), profit: isWin ? (Math.random() * 1).toFixed(4) : 0, isWin: isWin, isHighRoller: Math.random() > 0.9, }; setLiveBets(prev => [fakeBet, ...prev].slice(0, 20)); // Add fake chat occasionally if (Math.random() > 0.7) { const msg = { id: generateRandomId(), user: NAMES[Math.floor(Math.random() * NAMES.length)], text: MESSAGES[Math.floor(Math.random() * MESSAGES.length)], level: Math.floor(Math.random() * 10), }; setMessages(prev => [...prev, msg].slice(-30)); } }, 2000); return () => clearInterval(interval); }, []); const handleRoll = () => { if (betAmount > balance) return; if (betAmount <= 0) return; if (isRolling) return; setIsRolling(true); setRollResult(null); // deduct bet immediately setBalance(prev => prev - betAmount); // Simulate Network/Anim Delay setTimeout(() => { const result = Math.random() * 100; const finalResult = parseFloat(result.toFixed(2)); const win = finalResult < target; let payout = 0; let profit = -betAmount; if (win) { payout = betAmount * multiplier; profit = payout - betAmount; setBalance(prev => prev + payout); } setNetProfit(prev => prev + profit); setSeed(prev => ({ ...prev, nonce: prev.nonce + 1 })); setRollResult(finalResult); setIsRolling(false); const newBet = { id: generateRandomId(), user: 'You', bet: betAmount.toFixed(4), multiplier: multiplier.toFixed(2), profit: profit, isWin: win, target: target, result: finalResult }; setGameHistory(prev => [newBet, ...prev]); setLiveBets(prev => [newBet, ...prev].slice(0, 20)); // Trigger "High Roller" chat if big win if (win && profit > 0.5) { setMessages(prev => [...prev, { id: generateRandomId(), user: 'System', text: `BIG WIN! User You won ${profit.toFixed(4)} LTC!`, type: 'highroller' }]); } }, 600); // 600ms animation duration }; const handleSendMessage = (e) => { e.preventDefault(); const input = e.target.elements.msg; if (!input.value.trim()) return; setMessages(prev => [...prev, { id: generateRandomId(), user: 'You', text: input.value, level: level }]); input.value = ''; }; // --- Render Helpers --- const getSliderBackground = () => { const percentage = target; return { background: `linear-gradient(to right, #3b82f6 0%, #3b82f6 ${percentage}%, #374151 ${percentage}%, #374151 100%)` }; }; return (
{/* Modals */} {modal === 'provablyFair' && setModal(null)} {...seed} />} {modal === 'deposit' && setModal(null)} type="deposit" balance={balance} onAction={(amt) => setBalance(prev => prev + amt)} />} {modal === 'withdraw' && setModal(null)} type="withdraw" balance={balance} onAction={(amt) => setBalance(prev => prev - amt)} />} {/* --- Header --- */}
LITEDICE
Lvl {level}
Your Balance {balance.toFixed(4)} LTC
{/* --- Main Content --- */}
{/* Game Area */}
{/* Dice Board */}
{/* Provably Fair Badge */}
setModal('provablyFair')} className="absolute top-4 right-4 flex items-center gap-1 text-xs text-gray-500 hover:text-green-500 cursor-pointer transition" > Fairness
{/* Result Display */}
{/* The Track */}
{/* Winning Zone Marker */}
{/* The Slider/Dice */}
{isRolling ? : (rollResult !== null ? rollResult.toFixed(2) : "0.00")}
{/* Controls */}
{/* Sliders & Stats */}
Win Chance
{winChance.toFixed(2)}%
Roll Under {target.toFixed(2)}
setTarget(parseFloat(e.target.value))} style={getSliderBackground()} className="w-full h-3 bg-gray-700 rounded-lg appearance-none cursor-pointer slider-thumb-custom" />
{/* Bet Input & Button */}
BET AMOUNT LTC
setBetAmount(parseFloat(e.target.value))} className="flex-1 bg-transparent text-right text-xl font-mono font-bold text-white focus:outline-none px-2" />
Payout: {multiplier.toFixed(2)}x
Profit on Win: +{potentialProfit.toFixed(4)} LTC
{/* Recent Bets Table */}
{(activeTab === 'mine' ? gameHistory : liveBets) .filter(b => activeTab !== 'highrollers' || b.profit > 1.0 || b.isHighRoller) .map((bet) => ( ))} {liveBets.length === 0 && ( )}
Game User Bet Amount Multiplier Profit
Dice {bet.user} {parseFloat(bet.bet).toFixed(4)} LTC {bet.multiplier}x {bet.isWin ? '+' : ''}{parseFloat(bet.profit).toFixed(4)}
Waiting for bets...
{/* --- Chat Sidebar --- */}

Global Chat

{120 + Math.floor(Math.random()*50)} Online
{messages.map((msg) => (
{msg.type !== 'system' && (
{msg.level !== undefined && ( {msg.level} )} {msg.user} {new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}
)}

{msg.text}

))}
{/* Mobile Overlay for Chat */} {chatOpen && (
setChatOpen(false)} className="lg:hidden fixed inset-0 bg-black/50 z-20" /> )} {/* Global Styles for Range Slider */}
); }