This commit is contained in:
2025-08-03 21:49:49 +05:30
parent 40b8f367fe
commit f618a02ce3
4 changed files with 130 additions and 71 deletions

View File

@@ -4,7 +4,7 @@ import { GameState, MascotTier } from '../types'; // Import MascotTier
interface UpgradeShopProps {
gameState: GameState;
userClicks: number;
totalClicks: number; // Changed from userClicks
onPurchase: (upgradeId: string) => void;
}
@@ -12,13 +12,17 @@ interface UpgradeShopProps {
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({ gameState, userClicks, onPurchase }: UpgradeShopProps) {
export function UpgradeShop({ gameState, totalClicks, onPurchase }: UpgradeShopProps) { // Changed from userClicks
return (
<div className="bg-gradient-to-b from-purple-800 to-pink-600 p-6 rounded-xl border-4 border-cyan-400 shadow-2xl">
<h2 className="text-3xl font-bold text-yellow-300 mb-6 text-center" style={{ fontFamily: 'Comic Sans MS, cursive' }}>
@@ -29,7 +33,7 @@ export function UpgradeShop({ gameState, userClicks, onPurchase }: UpgradeShopPr
{UPGRADES.map((upgrade) => {
const owned = gameState.upgrades[upgrade.id]?.owned || 0;
const cost = gameState.upgrades[upgrade.id]?.cost || upgrade.baseCost;
const canAfford = userClicks >= cost;
const canAfford = totalClicks >= cost; // Changed from userClicks
let description = upgrade.description;
@@ -84,7 +88,7 @@ export function UpgradeShop({ gameState, userClicks, onPurchase }: UpgradeShopPr
<div className="mt-6 text-center">
<div className="text-2xl font-bold text-yellow-300">
Your Clicks: {userClicks.toLocaleString()}
Total Clicks: {totalClicks.toLocaleString()}
</div>
</div>
</div>