From c11a2dde948c41abd2df3bfc6675ebf765c0bb97 Mon Sep 17 00:00:00 2001 From: Ryan Lanny Jenkins Date: Sun, 25 May 2025 11:47:25 -0500 Subject: [PATCH] Add the aqua diffundere upgrades --- src/components/Temple.tsx | 13 +++++++++++++ src/constants/index.ts | 30 ++++++++++++++++++++++++++++++ src/store/useGameStore.ts | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/src/components/Temple.tsx b/src/components/Temple.tsx index 5a748c6..d53a419 100644 --- a/src/components/Temple.tsx +++ b/src/components/Temple.tsx @@ -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' } diff --git a/src/constants/index.ts b/src/constants/index.ts index 258d3e5..ef03e23 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -76,6 +76,36 @@ export const UPGRADES: Record = { }, ], }, + 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 { diff --git a/src/store/useGameStore.ts b/src/store/useGameStore.ts index f17cb0f..e7d695a 100644 --- a/src/store/useGameStore.ts +++ b/src/store/useGameStore.ts @@ -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 + ) + } + }) + } }), ) }