+
{user &&
}
@@ -72,6 +92,7 @@ const App = () => {
} />
+
diff --git a/src/components/Footer.jsx b/src/components/Footer.jsx
new file mode 100644
index 0000000..66bc3bc
--- /dev/null
+++ b/src/components/Footer.jsx
@@ -0,0 +1,11 @@
+import React from 'react';
+
+const Footer = () => {
+ return (
+
+ );
+};
+
+export default Footer;
\ No newline at end of file
diff --git a/src/components/Leaderboard.jsx b/src/components/Leaderboard.jsx
new file mode 100644
index 0000000..eaffdbe
--- /dev/null
+++ b/src/components/Leaderboard.jsx
@@ -0,0 +1,27 @@
+import React, { useEffect, useState } from 'react';
+
+const Leaderboard = () => {
+ const [leaderboard, setLeaderboard] = useState([]);
+
+ useEffect(() => {
+ const users = JSON.parse(localStorage.getItem('users')) || [];
+ const sortedUsers = users.sort((a, b) => b.balance - a.balance).slice(0, 10);
+ setLeaderboard(sortedUsers);
+ }, []);
+
+ return (
+
+
Leaderboard
+
+ {leaderboard.map((user, index) => (
+
+ {index + 1}. {user.username}
+ ${user.balance.toFixed(2)}
+
+ ))}
+
+
+ );
+};
+
+export default Leaderboard;
\ No newline at end of file
diff --git a/src/components/UpgradeSystem.jsx b/src/components/UpgradeSystem.jsx
new file mode 100644
index 0000000..42c64e2
--- /dev/null
+++ b/src/components/UpgradeSystem.jsx
@@ -0,0 +1,31 @@
+import React from 'react';
+import { Button } from "@/components/ui/button";
+
+const UpgradeSystem = ({ user, setUser }) => {
+ const upgradeCost = (user.moneyPerSecond || 1/3) * 100;
+
+ const handleUpgrade = () => {
+ if (user.balance >= upgradeCost) {
+ const updatedUser = {
+ ...user,
+ balance: user.balance - upgradeCost,
+ moneyPerSecond: (user.moneyPerSecond || 1/3) + 1/3
+ };
+ localStorage.setItem('user', JSON.stringify(updatedUser));
+ setUser(updatedUser);
+ } else {
+ alert("Insufficient balance for upgrade!");
+ }
+ };
+
+ return (
+
+
Upgrade Money Generation
+
Current rate: ${(user.moneyPerSecond || 1/3).toFixed(2)} per second
+
Upgrade cost: ${upgradeCost.toFixed(2)}
+
+
+ );
+};
+
+export default UpgradeSystem;
\ No newline at end of file
diff --git a/src/pages/Crash.jsx b/src/pages/Crash.jsx
index cbd4c64..3f614d2 100644
--- a/src/pages/Crash.jsx
+++ b/src/pages/Crash.jsx
@@ -15,6 +15,16 @@ const Crash = () => {
const canvasRef = useRef(null);
const [players, setPlayers] = useState([]);
+ useEffect(() => {
+ const storedUsers = JSON.parse(localStorage.getItem('users')) || [];
+ const activePlayers = storedUsers.filter(u => u.username !== user.username).slice(0, 10);
+ setPlayers(activePlayers.map(p => ({
+ username: p.username,
+ bet: Math.floor(Math.random() * 1000) + 10,
+ multiplier: 1,
+ })));
+ }, [user.username]);
+
useEffect(() => {
let interval;
if (gameState === 'playing') {
@@ -105,7 +115,7 @@ const Crash = () => {
setIsCrashed(false);
setMultiplier(1);
setTotalEarnings(0);
- simulatePlayers();
+ updatePlayerBets();
};
const handleCashOut = () => {
@@ -118,15 +128,20 @@ const Crash = () => {
});
setTotalEarnings(winnings);
setGameState('waiting');
+ updateAmountGambled(bet);
};
- const simulatePlayers = () => {
- const newPlayers = Array(Math.floor(Math.random() * 15) + 5).fill().map(() => ({
- username: `Player${Math.floor(Math.random() * 1000)}`,
- bet: Math.floor(Math.random() * 1000) + 10,
- multiplier: (Math.random() * 2 + 1).toFixed(2),
- }));
- setPlayers(newPlayers);
+ const updatePlayerBets = () => {
+ setPlayers(prev => prev.map(player => ({
+ ...player,
+ multiplier: player.multiplier * (Math.random() * 0.5 + 1),
+ })));
+ };
+
+ const updateAmountGambled = (amount) => {
+ const stats = JSON.parse(localStorage.getItem('userStats')) || {};
+ stats.amountGambled = (stats.amountGambled || 0) + amount;
+ localStorage.setItem('userStats', JSON.stringify(stats));
};
return (
diff --git a/src/pages/Dashboard.jsx b/src/pages/Dashboard.jsx
index 31f9810..c3e1db7 100644
--- a/src/pages/Dashboard.jsx
+++ b/src/pages/Dashboard.jsx
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { Button } from "@/components/ui/button";
+import Leaderboard from '../components/Leaderboard';
+import UpgradeSystem from '../components/UpgradeSystem';
const Dashboard = () => {
const [user, setUser] = useState(null);
@@ -8,6 +10,7 @@ const Dashboard = () => {
amountGambled: 0,
accountCreated: '',
lifetimeBalance: 0,
+ timeOnSite: 0,
});
useEffect(() => {
@@ -18,6 +21,7 @@ const Dashboard = () => {
amountGambled: 0,
accountCreated: new Date().toISOString(),
lifetimeBalance: storedUser.balance,
+ timeOnSite: 0,
};
setStats(storedStats);
}
@@ -38,6 +42,7 @@ const Dashboard = () => {
Amount Gambled: ${stats.amountGambled.toFixed(2)}
Account Created: {new Date(stats.accountCreated).toLocaleDateString()}
Lifetime Balance: ${stats.lifetimeBalance.toFixed(2)}
+ Time on Site: {Math.floor(stats.timeOnSite / 60)} minutes
Quick Links
@@ -54,6 +59,8 @@ const Dashboard = () => {
+
+
);
};