Compare commits

..

2 commits

Author SHA1 Message Date
Ryan Lanny Jenkins c11a2dde94 Add the aqua diffundere upgrades 2025-05-25 11:47:25 -05:00
Ryan Lanny Jenkins d7d3999401 Add perennial plants, starting with olives. 2025-05-25 11:29:31 -05:00
4 changed files with 121 additions and 3 deletions

View file

@ -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'
} }

View file

@ -22,6 +22,7 @@ export const CROPS: CropDefinitions = {
yield: 1, yield: 1,
yieldType: 'celery', yieldType: 'celery',
fertilityDepletion: 0.1, fertilityDepletion: 0.1,
seedType: 'celery_seed',
}, },
corn: { corn: {
id: 'corn', id: 'corn',
@ -31,6 +32,19 @@ export const CROPS: CropDefinitions = {
yield: 5, yield: 5,
yieldType: 'corn', yieldType: 'corn',
fertilityDepletion: 0.3, fertilityDepletion: 0.3,
seedType: 'corn_seed',
},
olive: {
id: 'olive',
name: 'Olive Tree',
growthTicks: 200,
waterPerTick: 1 / 50,
yield: 5,
yieldType: 'olive',
fertilityDepletion: 0.1,
seedType: 'olive', // Uses olives as seeds
isPerennial: true,
regrowthProgress: 150, // Resets to 150 ticks after harvest
}, },
} }
@ -62,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 {
@ -101,5 +145,18 @@ export const MARKET_ITEMS: Record<string, MarketItem> = {
buyPrice: null, buyPrice: null,
sellPrice: 5, sellPrice: 5,
}, },
corn: { id: 'corn', name: 'Corn', emoji: '🌽', buyPrice: null, sellPrice: 8 }, corn: {
id: 'corn',
name: 'Corn',
emoji: '🌽',
buyPrice: null,
sellPrice: 8,
},
olive: {
id: 'olive',
name: 'Olive',
emoji: '🫒',
buyPrice: 15,
sellPrice: null,
},
} }

View file

@ -144,7 +144,8 @@ export const useGameStore = create<
const plot = plots[row][col] const plot = plots[row][col]
if (plot.intended && !plot.current) { if (plot.intended && !plot.current) {
const seedId = `${plot.intended}_seed` const crop = CROPS[plot.intended]
const seedId = crop.seedType
if (inventory[seedId] && inventory[seedId] > 0) { if (inventory[seedId] && inventory[seedId] > 0) {
set( set(
@ -187,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
)
}
})
}
}), }),
) )
} }
@ -207,7 +241,18 @@ export const useGameStore = create<
set( set(
produce((state) => { produce((state) => {
if (crop.isPerennial) {
// For perennial crops, reset progress instead of clearing
state.plots[row][col].current = {
cropId: plot.current!.cropId,
progress: crop.regrowthProgress!,
mature: false,
}
} else {
// For regular crops, clear the plot
state.plots[row][col].current = undefined state.plots[row][col].current = undefined
}
state.inventory[yieldItem] = state.inventory[yieldItem] =
(state.inventory[yieldItem] || 0) + yieldAmount (state.inventory[yieldItem] || 0) + yieldAmount
state.plots[row][col].fertility = Math.max( state.plots[row][col].fertility = Math.max(

View file

@ -6,6 +6,9 @@ export interface Crop {
yield: number yield: number
yieldType: string yieldType: string
fertilityDepletion: number fertilityDepletion: number
seedType: string
isPerennial?: boolean
regrowthProgress?: number
} }
export interface CropDefinitions { export interface CropDefinitions {