From de827c37482a08b552bdfcb2b344c1dee7a2df1e Mon Sep 17 00:00:00 2001 From: Arjun S Date: Mon, 4 Aug 2025 00:49:44 +0530 Subject: [PATCH] fixed bozos --- party/index.ts | 13 +++++++------ src/App.tsx | 26 ++++++++++++++++++++------ src/components/ClickableMascot.tsx | 2 +- src/config/milestones.ts | 27 ++++++++++++++++++--------- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/party/index.ts b/party/index.ts index 5fd1f4f..02b8d81 100644 --- a/party/index.ts +++ b/party/index.ts @@ -183,12 +183,13 @@ const UPGRADES: Upgrade[] = [ ]; const MILESTONES = [ - { threshold: 100, id: 'first-hundred', background: 'rainbow', image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif' }, - { threshold: 500, id: 'five-hundred', background: 'matrix', image: 'https://media1.tenor.com/m/pV74fmh_NLgAAAAd/louie-rat-spinning-rat.gif' }, - { threshold: 1000, id: 'one-thousand', background: 'cyberpunk', image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif' }, - { threshold: 2500, id: 'epic-milestone', background: 'space', image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif' }, - { threshold: 5000, id: 'legendary', background: 'glitch', image: 'https://media1.tenor.com/m/pV74fmh_NLgAAAAd/louie-rat-spinning-rat.gif' }, - { threshold: 10000, id: 'ultimate', background: 'ultimate', image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif' } + { threshold: 1000, id: 'first-thousand', background: 'rainbow', image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif' }, + { threshold: 5000, id: 'five-thousand', background: 'matrix', image: 'https://media1.tenor.com/m/pV74fmh_NLgAAAAd/louie-rat-spinning-rat.gif' }, + { threshold: 10000, id: 'ten-thousand', background: 'cyberpunk', image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif' }, + { threshold: 50000, id: 'epic-milestone', background: 'space', image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif' }, + { threshold: 100000, id: 'legendary', background: 'glitch', image: 'https://media1.tenor.com/m/pV74fmh_NLgAAAAd/louie-rat-spinning-rat.gif' }, + { threshold: 500000, id: 'ultimate', background: 'ultimate', image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif' }, + { threshold: 1000000, id: 'god-tier', background: 'god-tier', image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif' } ]; export default class GameServer implements Party.Server { diff --git a/src/App.tsx b/src/App.tsx index 54350be..8fdc835 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,6 +23,8 @@ function App() { const [previousMilestones, setPreviousMilestones] = useState>({}); const [mascotEntities, setMascotEntities] = useState([]); const timeoutRef = useRef(null); + const gameStateRef = useRef(gameState); // Ref to hold the latest gameState + const clickButtonContainerRef = useRef(null); // New ref for the click button container const [location] = useLocation(); // Get current location from wouter const [adminBroadcastMessage, setAdminBroadcastMessage] = useState(null); // New state for admin messages @@ -66,12 +68,18 @@ function App() { } }, [lastMessage]); + // Effect to keep gameStateRef updated + useEffect(() => { + gameStateRef.current = gameState; + }, [gameState]); + // Effect for spawning mascots useEffect(() => { - if (!gameState) return; + // Use gameStateRef.current for initial check and to get latest state inside spawnMascot + if (!gameStateRef.current) return; const friendBoostUpgrade = UPGRADES.find(u => u.id === 'friendBoost') as Upgrade | undefined; - const ownedFriendBoost = gameState.upgrades['friendBoost']?.owned || 0; + const ownedFriendBoost = gameStateRef.current.upgrades['friendBoost']?.owned || 0; if (timeoutRef.current) { clearTimeout(timeoutRef.current); @@ -81,13 +89,19 @@ function App() { const baseInterval = 10000; // Increased base interval for less frequent spawns const minInterval = 1000; // Increased min interval const interval = Math.max(minInterval, baseInterval / (1 + ownedFriendBoost * 0.2)); // Adjusted scaling + console.log(`Spawning mascots every ${interval} ms for friendBoost level ${ownedFriendBoost}`); + const currentMascotTiers = friendBoostUpgrade.mascotTiers; // Ensure mascotTiers is not undefined const spawnMascot = () => { - const buttonContainer = document.getElementById('click-button-container'); + // Access the latest gameState from the ref inside the closure + const currentGameState = gameStateRef.current; + if (!currentGameState) return; // Should not happen if initial check passes + + const buttonContainer = clickButtonContainerRef.current; // Use the ref if (!buttonContainer) { - console.warn('Click button container not found!'); + console.warn('Click button container ref not found!'); timeoutRef.current = setTimeout(spawnMascot, 1000); // Retry after 1 second return; } @@ -152,7 +166,7 @@ function App() { clearTimeout(timeoutRef.current); } }; - }, [gameState?.upgrades['friendBoost']?.owned, gameState]); + }, [gameState?.upgrades['friendBoost']?.owned]); // Only depend on friendBoost level const handleMascotClick = (id: string, multiplierBonus: number) => { // Renamed handler sendMascotClickBonus(multiplierBonus); // Renamed function call @@ -234,7 +248,7 @@ function App() { {/* Main Content */}
{/* Left Column - Click Button */} -
{/* Added id and relative positioning */} +
{/* Added ref, id and relative positioning */} = ({ // Renamed fro setIsVisible(false); // Give some time for fade-out animation before actual removal setTimeout(() => onRemove(id), 500); - }, 7000); // Mascot disappears after 7 seconds if not clicked + }, 8000); // Mascot disappears after 8 seconds if not clicked return () => clearTimeout(timer); }, [id, onRemove]); diff --git a/src/config/milestones.ts b/src/config/milestones.ts index f02f59f..c8286b4 100644 --- a/src/config/milestones.ts +++ b/src/config/milestones.ts @@ -2,8 +2,8 @@ import { Milestone } from '../types'; export const MILESTONES: Milestone[] = [ { - threshold: 100, - id: 'first-hundred', + threshold: 1000, + id: 'first-thousand', name: 'First Steps', description: 'Welcome to the madness!', background: 'rainbow', @@ -11,8 +11,8 @@ export const MILESTONES: Milestone[] = [ reward: '🌈 Rainbow Background Unlocked!' }, { - threshold: 500, - id: 'five-hundred', + threshold: 5000, + id: 'five-thousand', name: 'Getting Warmed Up', description: 'The rat spins faster...', background: 'matrix', @@ -20,8 +20,8 @@ export const MILESTONES: Milestone[] = [ reward: '💊 Matrix Mode Activated!' }, { - threshold: 1000, - id: 'one-thousand', + threshold: 10000, + id: 'ten-thousand', name: 'Cyber Rat', description: 'Welcome to the future', background: 'cyberpunk', @@ -29,7 +29,7 @@ export const MILESTONES: Milestone[] = [ reward: '🦾 Cyberpunk Aesthetic Engaged!' }, { - threshold: 2500, + threshold: 50000, id: 'epic-milestone', name: 'Space Cadet', description: 'To infinity and beyond!', @@ -38,7 +38,7 @@ export const MILESTONES: Milestone[] = [ reward: '🚀 Space Background Unlocked!' }, { - threshold: 5000, + threshold: 100000, id: 'legendary', name: 'Glitch in the Matrix', description: 'Reality is breaking down', @@ -47,12 +47,21 @@ export const MILESTONES: Milestone[] = [ reward: '⚡ Glitch Effect Activated!' }, { - threshold: 10000, + threshold: 500000, id: 'ultimate', name: 'Ultimate Bozo', description: 'You have achieved peak bozo status', background: 'ultimate', image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif', reward: '👑 Ultimate Power Unlocked!' + }, + { + threshold: 1000000, + id: 'god-tier', + name: 'God Tier Bozo', + description: 'You are the ultimate bozo', + background: 'god-tier', + image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif', + reward: '🌟 God Mode Activated!' } ]; \ No newline at end of file