Add some stamina upgrades.

This commit is contained in:
Ryan Lanny Jenkins 2025-06-07 19:58:15 -05:00
parent 453910282a
commit 9ada074b12
4 changed files with 94 additions and 62 deletions

View file

@ -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,7 +163,9 @@ const TempleComponent: React.FC = () => {
</PrayerSection>
<UpgradesGrid>
{Object.values(UPGRADES).map((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)

View file

@ -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<string, Upgrade> = {
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',

View file

@ -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)
}
}),
)
},

View file

@ -48,6 +48,7 @@ export interface Upgrade {
name: string
description: string
cost: UpgradeCost[]
isAvailable?: (state: Pick<GameState, 'purchasedUpgrades' | 'milestones'>) => boolean
}
export interface Recipe {