harvest/game/scripts/crop_unit.gd
Forrest 62edb8e04c Task #13: two new crop fields with staged growth (Night 2 / Night 4)
Adds a Lettuce/Cabbage field (ids 31-40, x -11..-1 z 2..12) and a Corn field
(ids 41-50, x 2..12 z 2..12), each 2 plots of 5 units, placeholder plants
reusing plant_007/plant_008. CropUnit gains crop (cosmetic) and sprout_night
(0/2/4) fields. LootSystem gains a DORMANT status: a unit whose field hasn't
sprouted (FarmState.nights_survived < sprout_night) is hidden and never
claimable/recoverable, and is excluded from crops_total so it can't affect
scoring or the "farm stripped" check. sync_from_state() derives DORMANT vs.
HOME from nights_survived every morning (and after a retry/load), and
self-heals crops_total to the sprouted count; FarmSim.grow_crops_total() also
grows it right at night_ending so the morning snapshot (retry, the save file)
already has it right. FarmZones.crop_units() now gathers CropUnits from every
CROP_FIELD zone (there are three now), not just the first found; the same fix
applies to FarmSim's crop-area rect and the fence breakers' guarded areas.

Reworks test_farm_layout's zone-count and crop checks for the extra fields,
and test_theft's start-of-run and FarmState-consistency checks, which assumed
every crop unit was always in play; adds test_theft cases for both fields
sprouting on schedule, dormant units being unclaimable, and a sprouted unit
being stealable and scored, including a save/JSON round trip. Nudges
test_coop's co-op build spot into the 3 m walkway between the two new fields,
since its old spot now sits on the corn field's rows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 15:52:38 -04:00

16 lines
941 B
GDScript

class_name CropUnit
extends Node3D
## One stealable crop unit: a cluster of plants (this node's children) with one ID in FarmState.
## The original crop field holds 6 plots of 5 units; each unit is one row segment of its plot.
## #13: two more fields (lettuce/cabbage, corn), each 2 plots of 5 units, sprout later in the
## campaign: dormant (hidden, unclaimable) until FarmState.nights_survived reaches sprout_night,
## then home like any other crop (LootSystem.sync_from_state derives this every morning).
@export var unit_id: int = 0
@export var plot: int = 0
## "sunflower" (the original field), "lettuce", or "corn" (#13). Cosmetic only; LootSystem
## groups theft rules by category, not by this.
@export var crop: String = "sunflower"
## The night that must be survived (FarmState.nights_survived) before this unit sprouts and
## becomes stealable. 0 = already grown, in play from the first morning.
@export var sprout_night: int = 0