Add the aqua diffundere upgrades

This commit is contained in:
Ryan Lanny Jenkins 2025-05-25 11:47:25 -05:00
parent d7d3999401
commit c11a2dde94
3 changed files with 76 additions and 0 deletions

View file

@ -148,6 +148,13 @@ const TempleComponent: React.FC = () => {
return false
}
if (
upgrade.id === 'aqua_diffundere_2' &&
!purchasedUpgrades.includes('aqua_diffundere_1')
) {
return false
}
return true
}
@ -161,6 +168,12 @@ const TempleComponent: React.FC = () => {
) {
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'
}

View file

@ -76,6 +76,36 @@ export const UPGRADES: Record<string, Upgrade> = {
},
],
},
aqua_diffundere_1: {
id: 'aqua_diffundere_1',
name: 'Aqua Diffundere I',
description: 'Watering a plot also increases water level of adjacent plots by 10%',
cost: [
{
itemId: 'celery',
amount: 10,
},
{
itemId: 'corn',
amount: 15,
},
],
},
aqua_diffundere_2: {
id: 'aqua_diffundere_2',
name: 'Aqua Diffundere II',
description: 'Watering a plot also increases water level of adjacent plots by 30% (requires Aqua Diffundere I)',
cost: [
{
itemId: 'corn',
amount: 100,
},
{
itemId: 'celery',
amount: 25,
},
],
},
}
export interface MarketItem {

View file

@ -188,6 +188,39 @@ export const useGameStore = create<
produce((state) => {
state.plots[row][col].moisture = 1
state.actionCooldown = finalCooldown
// Handle water diffusion to adjacent plots
const diffusionAmount = purchasedUpgrades.includes('aqua_diffundere_2')
? 0.3
: purchasedUpgrades.includes('aqua_diffundere_1')
? 0.1
: 0
if (diffusionAmount > 0) {
// Check and water adjacent plots (up, right, down, left)
const adjacentPositions = [
[row - 1, col], // up
[row, col + 1], // right
[row + 1, col], // down
[row, col - 1], // left
]
adjacentPositions.forEach(([adjRow, adjCol]) => {
// Check if the adjacent position is within bounds
if (
adjRow >= 0 &&
adjRow < state.plots.length &&
adjCol >= 0 &&
adjCol < state.plots[0].length
) {
const adjPlot = state.plots[adjRow][adjCol]
state.plots[adjRow][adjCol].moisture = Math.min(
1,
adjPlot.moisture + diffusionAmount
)
}
})
}
}),
)
}