diff --git a/src/components/Temple.tsx b/src/components/Temple.tsx index 10381f2..8c00ad7 100644 --- a/src/components/Temple.tsx +++ b/src/components/Temple.tsx @@ -115,6 +115,7 @@ const TempleComponent: React.FC = () => { pray, piety, stamina, + milestones, } = useGameStore() const handlePurchase = (upgradeId: string) => { @@ -136,44 +137,13 @@ const TempleComponent: React.FC = () => { } // Check if can afford - if (!canAffordUpgrade(upgrade.cost)) { - return false - } - - // Check requirements - if ( - upgrade.id === 'aqueous_vigor_2' && - !purchasedUpgrades.includes('aqueous_vigor_1') - ) { - return false - } - - if ( - upgrade.id === 'aqua_diffundere_2' && - !purchasedUpgrades.includes('aqua_diffundere_1') - ) { - return false - } - - return true + return canAffordUpgrade(upgrade.cost) } const getUpgradeStatus = (upgrade: Upgrade) => { if (purchasedUpgrades.includes(upgrade.id)) { return 'Purchased' } - if ( - upgrade.id === 'aqueous_vigor_2' && - !purchasedUpgrades.includes('aqueous_vigor_1') - ) { - return 'Requires Aqueous Vigor I' - } - if ( - upgrade.id === 'aqua_diffundere_2' && - !purchasedUpgrades.includes('aqua_diffundere_1') - ) { - return 'Requires Aqua Diffundere I' - } if (!canAffordUpgrade(upgrade.cost)) { return 'Cannot Afford' } @@ -193,35 +163,37 @@ const TempleComponent: React.FC = () => { - {Object.values(UPGRADES).map((upgrade) => { - const isPurchased = purchasedUpgrades.includes(upgrade.id) - const canPurchase = canPurchaseUpgrade(upgrade) - const status = getUpgradeStatus(upgrade) + {Object.values(UPGRADES) + .filter(upgrade => !upgrade.isAvailable || upgrade.isAvailable({ purchasedUpgrades, milestones })) + .map((upgrade) => { + const isPurchased = purchasedUpgrades.includes(upgrade.id) + const canPurchase = canPurchaseUpgrade(upgrade) + const status = getUpgradeStatus(upgrade) - return ( - - {upgrade.name} - {upgrade.description} - - Cost: - {upgrade.cost.map((cost, index) => ( - - - {cost.amount} {cost.itemId} - - (You have: {inventory[cost.itemId] || 0}) - - ))} - - handlePurchase(upgrade.id)} - disabled={!canPurchase} - > - {status} - - - ) - })} + return ( + + {upgrade.name} + {upgrade.description} + + Cost: + {upgrade.cost.map((cost, index) => ( + + + {cost.amount} {cost.itemId} + + (You have: {inventory[cost.itemId] || 0}) + + ))} + + handlePurchase(upgrade.id)} + disabled={!canPurchase} + > + {status} + + + ) + })} ) diff --git a/src/constants/index.ts b/src/constants/index.ts index 244aabd..fa226d0 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -17,8 +17,8 @@ export const CROPS: CropDefinitions = { celery: { id: 'celery', name: 'Celery', - growthTicks: 36, - waterPerTick: 1 / 20, + growthTicks: 10, + waterPerTick: 1 / 5, yield: 1, yieldType: 'celery', fertilityDepletion: 0.1, @@ -65,6 +65,50 @@ export const INITIAL_INVENTORY = { } export const UPGRADES: Record = { + stamina_1: { + id: 'stamina_1', + name: 'Stamina I', + description: 'Increases maximum stamina by 5', + cost: [ + { + itemId: 'celery', + amount: 20, + }, + ], + }, + stamina_2: { + id: 'stamina_2', + name: 'Stamina II', + description: 'Increases maximum stamina by 8', + cost: [ + { + itemId: 'corn', + amount: 20, + }, + ], + }, + stamina_3: { + id: 'stamina_3', + name: 'Stamina III', + description: 'Increases maximum stamina by 12', + cost: [ + { + itemId: 'olives', + amount: 100, + }, + ], + }, + stamina_4: { + id: 'stamina_4', + name: 'Stamina IV', + description: 'Increases maximum stamina by 15', + cost: [ + { + itemId: 'grapes', + amount: 100, + }, + ], + }, aqueous_vigor_1: { id: 'aqueous_vigor_1', name: 'Aqueous Vigor I', diff --git a/src/store/useGameStore.ts b/src/store/useGameStore.ts index 32f4b4b..5c8002b 100644 --- a/src/store/useGameStore.ts +++ b/src/store/useGameStore.ts @@ -505,6 +505,21 @@ export const useGameStore = create< }) state.purchasedUpgrades.push(upgradeId) addConsoleMessage(state, `Purchased upgrade: ${upgrade.name}`) + + // Handle stamina upgrades + if (upgradeId === 'stamina_1') { + state.maxStamina += 5 + state.stamina = Math.min(state.maxStamina, state.stamina + 5) + } else if (upgradeId === 'stamina_2') { + state.maxStamina += 8 + state.stamina = Math.min(state.maxStamina, state.stamina + 8) + } else if (upgradeId === 'stamina_3') { + state.maxStamina += 12 + state.stamina = Math.min(state.maxStamina, state.stamina + 12) + } else if (upgradeId === 'stamina_4') { + state.maxStamina += 15 + state.stamina = Math.min(state.maxStamina, state.stamina + 15) + } }), ) }, diff --git a/src/types/index.ts b/src/types/index.ts index 5841773..25c01b0 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -48,6 +48,7 @@ export interface Upgrade { name: string description: string cost: UpgradeCost[] + isAvailable?: (state: Pick) => boolean } export interface Recipe {