- {/* Plinko board visualization would go here */}
-
Plinko Board Visualization
-
- {['8.9x', '3x', '1.4x', '1.1x', '1x', '0.5x', '1x', '1.1x', '1.4x', '3x', '8.9x'].map((multiplier, index) => (
-
- {multiplier}
-
- ))}
+
@@ -94,4 +114,4 @@ const Plinko = () => {
);
};
-export default Plinko;
\ No newline at end of file
+export default Plinko;
diff --git a/src/pages/Towers.jsx b/src/pages/Towers.jsx
index 0ec74c7..bdd3ce6 100644
--- a/src/pages/Towers.jsx
+++ b/src/pages/Towers.jsx
@@ -1,7 +1,12 @@
import React, { useState, useEffect } from 'react';
import { Button } from "@/components/ui/button";
import Header from '../components/Header';
-import ChatBox from '../components/ChatBox';
+
+const difficultySettings = {
+ easy: { levels: 4, successRate: 0.7, multiplier: 1.2 },
+ medium: { levels: 8, successRate: 0.5, multiplier: 1.5 },
+ hard: { levels: 12, successRate: 0.3, multiplier: 2 }
+};
const Towers = () => {
const [user, setUser] = useState(JSON.parse(localStorage.getItem('user')));
@@ -9,9 +14,20 @@ const Towers = () => {
const [currentLevel, setCurrentLevel] = useState(0);
const [gameOver, setGameOver] = useState(false);
const [totalEarnings, setTotalEarnings] = useState(0);
- const [towerState, setTowerState] = useState(Array(10).fill().map(() => Array(3).fill('default')));
+ const [difficulty, setDifficulty] = useState('medium');
+ const [towerState, setTowerState] = useState([]);
- const levels = 10;
+ useEffect(() => {
+ initializeTower();
+ }, [difficulty]);
+
+ const initializeTower = () => {
+ const { levels } = difficultySettings[difficulty];
+ setTowerState(Array(levels).fill().map(() => Array(3).fill('default')));
+ setCurrentLevel(0);
+ setGameOver(false);
+ setTotalEarnings(0);
+ };
const handleStart = () => {
if (bet > user.balance) {
@@ -23,16 +39,13 @@ const Towers = () => {
localStorage.setItem('user', JSON.stringify(updatedUser));
return updatedUser;
});
- setCurrentLevel(0);
- setGameOver(false);
- setTotalEarnings(0);
- setTowerState(Array(10).fill().map(() => Array(3).fill('default')));
+ initializeTower();
};
const handleClimb = (level, choice) => {
if (gameOver || level !== currentLevel) return;
- const successRate = 0.5; // 50% win rate
+ const { successRate, multiplier } = difficultySettings[difficulty];
const isSuccess = Math.random() < successRate;
const newTowerState = [...towerState];
@@ -43,7 +56,7 @@ const Towers = () => {
setCurrentLevel(prev => prev + 1);
const newEarnings = calculateEarnings(currentLevel + 1);
setTotalEarnings(newEarnings);
- if (currentLevel + 1 === levels) {
+ if (currentLevel + 1 === difficultySettings[difficulty].levels) {
handleWin();
}
} else {
@@ -52,7 +65,8 @@ const Towers = () => {
};
const calculateEarnings = (level) => {
- return bet * (1 + (level * 0.5));
+ const { multiplier } = difficultySettings[difficulty];
+ return bet * (1 + (level * multiplier));
};
const handleCashOut = () => {
@@ -74,63 +88,74 @@ const Towers = () => {
};
return (
-
-
-
-
-
-
-
-
-
- setBet(Number(e.target.value))}
- className="bg-darkBlue text-white p-2 rounded mr-2 w-full"
- />
-
-
-
-
+
+
+
+
+
+
+
+
+ {Object.keys(difficultySettings).map((diff) => (
+
+ ))}
-
-
-
${totalEarnings.toFixed(2)}
+
+
+
+
+ setBet(Number(e.target.value))}
+ className="bg-darkBlue text-white p-2 rounded mr-2 w-full"
+ />
+
+
+
-
- {!gameOver && currentLevel > 0 && (
-
- )}
+
+
+
${totalEarnings.toFixed(2)}
+
+
+ {!gameOver && currentLevel > 0 && (
+
+ )}
-
-
-
- {towerState.map((row, level) => (
-
- {row.map((state, choice) => (
-
- ))}
-
- ))}
-
+
+
+
+
+ {towerState.map((row, level) => (
+
+ {row.map((state, choice) => (
+
+ ))}
+
+ ))}
-
);
};