import React from 'react'; import { UPGRADES } from '../config/upgrades'; import { GameState, MascotTier, UserState } from '../types'; // Import MascotTier interface UpgradeShopProps { gameState: GameState; userState: UserState | null; onPurchase: (upgradeId: string) => void; } // Helper function to get mascot name from image source const getMascotName = (imageSrc: string): string => { const fileName = imageSrc.split('/').pop() || ''; const nameWithoutExtension = fileName.split('.')[0]; // remove the word neurosama if it exists in the name if (nameWithoutExtension.includes('neurosama')) { return nameWithoutExtension.replace('neurosama', '').trim(); } return nameWithoutExtension .split('-') .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); }; export function UpgradeShop({ userState, onPurchase }: UpgradeShopProps) { // Changed from userClicks if (!userState) { return null; // Or a loading/signed-out state } const { clicks: userClicks, upgrades: userUpgrades } = userState; return (

✨ BOZO SHOP ✨

{UPGRADES.map((upgrade) => { const owned = userUpgrades[upgrade.id]?.owned || 0; const cost = userUpgrades[upgrade.id]?.cost || upgrade.baseCost; const canAfford = userClicks >= cost; // If it's a one-time upgrade and already owned, don't display it if (upgrade.oneTime && owned > 0) { return null; } let description = upgrade.description; // Custom description for Friend Boost upgrade if (upgrade.id === 'friendBoost' && upgrade.mascotTiers) { const nextMascotTier = upgrade.mascotTiers.find( (tier: MascotTier) => owned < tier.level ); if (nextMascotTier) { description = `Spawns various clickable friends. Next: ${getMascotName(nextMascotTier.imageSrc)} at level ${nextMascotTier.level}`; } else { description = 'All mascots unlocked! Spawns various clickable friends.'; } } return (
canAfford && onPurchase(upgrade.id)} >
{upgrade.icon}

{upgrade.name}

{owned > 0 && ( {owned} )}

{description}

{cost.toLocaleString()}
clicks
); })}
Your Clicks: {userClicks.toLocaleString()}
); }