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>
This commit is contained in:
Forrest 2026-10-05 15:52:38 -04:00
parent 0613cca408
commit 62edb8e04c
8 changed files with 974 additions and 28 deletions

View file

@ -31,7 +31,8 @@ func zone_at(point: Vector3) -> FarmZone:
return null
## The farm's own zone of a kind (never an outside one).
## The farm's own zone of a kind (never an outside one). When a kind has more than one zone
## (#13: three CROP_FIELD zones), this is just the first found: use zones_of() for all of them.
func zone(kind: FarmZone.Kind) -> FarmZone:
for z in zones():
if z.kind == kind:
@ -39,6 +40,15 @@ func zone(kind: FarmZone.Kind) -> FarmZone:
return null
## Every one of the farm's own zones of a kind, in scene order.
func zones_of(kind: FarmZone.Kind) -> Array[FarmZone]:
var out: Array[FarmZone] = []
for z in zones():
if z.kind == kind:
out.append(z)
return out
## The gathering areas beyond the fence.
func outside_zones() -> Array[FarmZone]:
var out: Array[FarmZone] = []
@ -109,12 +119,11 @@ func side_of(p: Vector2) -> String:
return ns + "-" + we if ns != "" and we != "" else ns + we
## Every CropUnit in every CROP_FIELD zone (#13: the original field plus the two later ones).
func crop_units() -> Array[CropUnit]:
var out: Array[CropUnit] = []
var field := zone(FarmZone.Kind.CROP_FIELD)
if field == null:
return out
for node in field.find_children("*", "Node3D", true, false):
if node is CropUnit:
out.append(node)
for field in zones_of(FarmZone.Kind.CROP_FIELD):
for node in field.find_children("*", "Node3D", true, false):
if node is CropUnit:
out.append(node)
return out