From 301c955058bba4594a3ef5d501f8633ed068dff8 Mon Sep 17 00:00:00 2001 From: billy Date: Sun, 30 Mar 2025 03:47:35 -0400 Subject: [PATCH] idc --- src/App.tsx | 11 ++- src/components/BuildingButton.tsx | 107 ++++++++++++++++-------------- src/components/ResetButton.tsx | 63 ++++++++++++++++++ 3 files changed, 127 insertions(+), 54 deletions(-) create mode 100644 src/components/ResetButton.tsx diff --git a/src/App.tsx b/src/App.tsx index 7bb5c0b..a325cdd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import { ResourceDisplay } from './components/ResourceDisplay' import { BuildingButton } from './components/BuildingButton' import { MultiplierShop } from './components/MultiplierShop' import { NextBuildingPreview } from './components/NextBuildingPreview' +import { ResetButton } from './components/ResetButton' import { useGameStore } from './store/gameStore' import { ChakraProvider, @@ -11,7 +12,8 @@ import { Text, VStack, SimpleGrid, - Button + Button, + Flex } from '@chakra-ui/react' import theme from './theme' import { useEffect } from 'react' @@ -138,8 +140,11 @@ function App() { - - Clicker Clicker 2 + + + Clicker Clicker 2 + + Level {playerLevel} diff --git a/src/components/BuildingButton.tsx b/src/components/BuildingButton.tsx index d1c5864..efd19dd 100644 --- a/src/components/BuildingButton.tsx +++ b/src/components/BuildingButton.tsx @@ -4,7 +4,8 @@ import { VStack, Text, Badge, - Tooltip + Tooltip, + HStack } from '@chakra-ui/react' import { useGameStore } from '../store/gameStore' @@ -15,10 +16,7 @@ interface BuildingButtonProps { level: number onClick: () => void description: string - production: { - points?: number - techParts?: number - } + production: { points?: number } buildingType: string levelRequirement: number } @@ -34,58 +32,65 @@ export function BuildingButton({ buildingType, levelRequirement }: BuildingButtonProps) { - const { points, playerLevel } = useGameStore() + const { points, playerLevel, upgradeBuilding } = useGameStore() const canAfford = points >= cost const meetsLevelRequirement = playerLevel >= levelRequirement const isDisabled = !canAfford || !meetsLevelRequirement - const buttonContent = ( - - - {title} - 1 ? 'green' : 'gray'}>Level {level} - - {description} - - Owned: {owned} - Cost: {cost} points - - - Production: - {production.points && ( - Points: {production.points}/s - )} - {production.techParts && ( - Tech Parts: {production.techParts}/s - )} - - - ) + // Calculate upgrade cost + const calculateUpgradeCost = (currentLevel: number): number => { + return Math.floor(cost * Math.pow(1.5, currentLevel - 1)) + } + + const upgradeCost = calculateUpgradeCost(level) + const canUpgrade = points >= upgradeCost && owned > 0 + const pointsPerSecond = production.points || 0 return ( - - - + + + {title} + + Owned: {owned} + Level: {level} + + + {description} + + Production: + Points: {(pointsPerSecond * level).toFixed(1)}/s per building + Total: {(pointsPerSecond * level * owned).toFixed(1)}/s + + + + + + + + + ) } \ No newline at end of file diff --git a/src/components/ResetButton.tsx b/src/components/ResetButton.tsx new file mode 100644 index 0000000..818140d --- /dev/null +++ b/src/components/ResetButton.tsx @@ -0,0 +1,63 @@ +import { + Button, + AlertDialog, + AlertDialogBody, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogContent, + AlertDialogOverlay, + useDisclosure +} from '@chakra-ui/react' +import React, { useRef } from 'react' +import { useGameStore } from '../store/gameStore' + +export function ResetButton() { + const { resetGame } = useGameStore() + const { isOpen, onOpen, onClose } = useDisclosure() + const cancelRef = useRef(null) + + const handleReset = () => { + resetGame() + onClose() + } + + return ( + <> + + + } + onClose={onClose} + > + + + + Reset Game + + + + Are you sure? You will lose all progress and start from the beginning. + + + + + + + + + + + ) +} \ No newline at end of file