fixed bozos
This commit is contained in:
@@ -183,12 +183,13 @@ const UPGRADES: Upgrade[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const MILESTONES = [
|
const MILESTONES = [
|
||||||
{ threshold: 100, id: 'first-hundred', background: 'rainbow', image: 'https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/spinning-rat-rat.gif' },
|
{ threshold: 1000, id: 'first-thousand', 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: 5000, id: 'five-thousand', 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: 10000, id: 'ten-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: 50000, 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: 100000, 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: 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 {
|
export default class GameServer implements Party.Server {
|
||||||
|
|||||||
26
src/App.tsx
26
src/App.tsx
@@ -23,6 +23,8 @@ function App() {
|
|||||||
const [previousMilestones, setPreviousMilestones] = useState<Record<string, boolean>>({});
|
const [previousMilestones, setPreviousMilestones] = useState<Record<string, boolean>>({});
|
||||||
const [mascotEntities, setMascotEntities] = useState<ClickableMascotType[]>([]);
|
const [mascotEntities, setMascotEntities] = useState<ClickableMascotType[]>([]);
|
||||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
const gameStateRef = useRef(gameState); // Ref to hold the latest gameState
|
||||||
|
const clickButtonContainerRef = useRef<HTMLDivElement>(null); // New ref for the click button container
|
||||||
const [location] = useLocation(); // Get current location from wouter
|
const [location] = useLocation(); // Get current location from wouter
|
||||||
const [adminBroadcastMessage, setAdminBroadcastMessage] = useState<string | null>(null); // New state for admin messages
|
const [adminBroadcastMessage, setAdminBroadcastMessage] = useState<string | null>(null); // New state for admin messages
|
||||||
|
|
||||||
@@ -66,12 +68,18 @@ function App() {
|
|||||||
}
|
}
|
||||||
}, [lastMessage]);
|
}, [lastMessage]);
|
||||||
|
|
||||||
|
// Effect to keep gameStateRef updated
|
||||||
|
useEffect(() => {
|
||||||
|
gameStateRef.current = gameState;
|
||||||
|
}, [gameState]);
|
||||||
|
|
||||||
// Effect for spawning mascots
|
// Effect for spawning mascots
|
||||||
useEffect(() => {
|
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 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) {
|
if (timeoutRef.current) {
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
@@ -81,13 +89,19 @@ function App() {
|
|||||||
const baseInterval = 10000; // Increased base interval for less frequent spawns
|
const baseInterval = 10000; // Increased base interval for less frequent spawns
|
||||||
const minInterval = 1000; // Increased min interval
|
const minInterval = 1000; // Increased min interval
|
||||||
const interval = Math.max(minInterval, baseInterval / (1 + ownedFriendBoost * 0.2)); // Adjusted scaling
|
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 currentMascotTiers = friendBoostUpgrade.mascotTiers; // Ensure mascotTiers is not undefined
|
||||||
|
|
||||||
const spawnMascot = () => {
|
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) {
|
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
|
timeoutRef.current = setTimeout(spawnMascot, 1000); // Retry after 1 second
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -152,7 +166,7 @@ function App() {
|
|||||||
clearTimeout(timeoutRef.current);
|
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
|
const handleMascotClick = (id: string, multiplierBonus: number) => { // Renamed handler
|
||||||
sendMascotClickBonus(multiplierBonus); // Renamed function call
|
sendMascotClickBonus(multiplierBonus); // Renamed function call
|
||||||
@@ -234,7 +248,7 @@ function App() {
|
|||||||
{/* Main Content */}
|
{/* Main Content */}
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
||||||
{/* Left Column - Click Button */}
|
{/* Left Column - Click Button */}
|
||||||
<div id="click-button-container" className="lg:col-span-1 flex flex-col items-center justify-center relative"> {/* Added id and relative positioning */}
|
<div ref={clickButtonContainerRef} id="click-button-container" className="lg:col-span-1 flex flex-col items-center justify-center relative"> {/* Added ref, id and relative positioning */}
|
||||||
<ClickButton
|
<ClickButton
|
||||||
onClick={sendClick}
|
onClick={sendClick}
|
||||||
imageUrl={gameState.currentClickImage}
|
imageUrl={gameState.currentClickImage}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const ClickableMascot: React.FC<ClickableMascotProps> = ({ // Renamed fro
|
|||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
// Give some time for fade-out animation before actual removal
|
// Give some time for fade-out animation before actual removal
|
||||||
setTimeout(() => onRemove(id), 500);
|
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);
|
return () => clearTimeout(timer);
|
||||||
}, [id, onRemove]);
|
}, [id, onRemove]);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { Milestone } from '../types';
|
|||||||
|
|
||||||
export const MILESTONES: Milestone[] = [
|
export const MILESTONES: Milestone[] = [
|
||||||
{
|
{
|
||||||
threshold: 100,
|
threshold: 1000,
|
||||||
id: 'first-hundred',
|
id: 'first-thousand',
|
||||||
name: 'First Steps',
|
name: 'First Steps',
|
||||||
description: 'Welcome to the madness!',
|
description: 'Welcome to the madness!',
|
||||||
background: 'rainbow',
|
background: 'rainbow',
|
||||||
@@ -11,8 +11,8 @@ export const MILESTONES: Milestone[] = [
|
|||||||
reward: '🌈 Rainbow Background Unlocked!'
|
reward: '🌈 Rainbow Background Unlocked!'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
threshold: 500,
|
threshold: 5000,
|
||||||
id: 'five-hundred',
|
id: 'five-thousand',
|
||||||
name: 'Getting Warmed Up',
|
name: 'Getting Warmed Up',
|
||||||
description: 'The rat spins faster...',
|
description: 'The rat spins faster...',
|
||||||
background: 'matrix',
|
background: 'matrix',
|
||||||
@@ -20,8 +20,8 @@ export const MILESTONES: Milestone[] = [
|
|||||||
reward: '💊 Matrix Mode Activated!'
|
reward: '💊 Matrix Mode Activated!'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
threshold: 1000,
|
threshold: 10000,
|
||||||
id: 'one-thousand',
|
id: 'ten-thousand',
|
||||||
name: 'Cyber Rat',
|
name: 'Cyber Rat',
|
||||||
description: 'Welcome to the future',
|
description: 'Welcome to the future',
|
||||||
background: 'cyberpunk',
|
background: 'cyberpunk',
|
||||||
@@ -29,7 +29,7 @@ export const MILESTONES: Milestone[] = [
|
|||||||
reward: '🦾 Cyberpunk Aesthetic Engaged!'
|
reward: '🦾 Cyberpunk Aesthetic Engaged!'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
threshold: 2500,
|
threshold: 50000,
|
||||||
id: 'epic-milestone',
|
id: 'epic-milestone',
|
||||||
name: 'Space Cadet',
|
name: 'Space Cadet',
|
||||||
description: 'To infinity and beyond!',
|
description: 'To infinity and beyond!',
|
||||||
@@ -38,7 +38,7 @@ export const MILESTONES: Milestone[] = [
|
|||||||
reward: '🚀 Space Background Unlocked!'
|
reward: '🚀 Space Background Unlocked!'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
threshold: 5000,
|
threshold: 100000,
|
||||||
id: 'legendary',
|
id: 'legendary',
|
||||||
name: 'Glitch in the Matrix',
|
name: 'Glitch in the Matrix',
|
||||||
description: 'Reality is breaking down',
|
description: 'Reality is breaking down',
|
||||||
@@ -47,12 +47,21 @@ export const MILESTONES: Milestone[] = [
|
|||||||
reward: '⚡ Glitch Effect Activated!'
|
reward: '⚡ Glitch Effect Activated!'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
threshold: 10000,
|
threshold: 500000,
|
||||||
id: 'ultimate',
|
id: 'ultimate',
|
||||||
name: 'Ultimate Bozo',
|
name: 'Ultimate Bozo',
|
||||||
description: 'You have achieved peak bozo status',
|
description: 'You have achieved peak bozo status',
|
||||||
background: 'ultimate',
|
background: 'ultimate',
|
||||||
image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif',
|
image: 'https://media1.tenor.com/m/YsWlbVbRWFQAAAAd/rat-spinning.gif',
|
||||||
reward: '👑 Ultimate Power Unlocked!'
|
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!'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
Reference in New Issue
Block a user