Add perennial plants, starting with olives.

This commit is contained in:
Ryan Lanny Jenkins 2025-05-25 11:29:31 -05:00
parent 23c312299c
commit d7d3999401
3 changed files with 45 additions and 3 deletions

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
}, },
} }
@ -101,5 +115,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(
@ -207,7 +208,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 {