Add the aqua diffundere upgrades
This commit is contained in:
parent
d7d3999401
commit
c11a2dde94
|
|
@ -148,6 +148,13 @@ const TempleComponent: React.FC = () => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
upgrade.id === 'aqua_diffundere_2' &&
|
||||||
|
!purchasedUpgrades.includes('aqua_diffundere_1')
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,6 +168,12 @@ const TempleComponent: React.FC = () => {
|
||||||
) {
|
) {
|
||||||
return 'Requires Aqueous Vigor I'
|
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)) {
|
if (!canAffordUpgrade(upgrade.cost)) {
|
||||||
return 'Cannot Afford'
|
return 'Cannot Afford'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
export interface MarketItem {
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,39 @@ export const useGameStore = create<
|
||||||
produce((state) => {
|
produce((state) => {
|
||||||
state.plots[row][col].moisture = 1
|
state.plots[row][col].moisture = 1
|
||||||
state.actionCooldown = finalCooldown
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue