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:
parent
0613cca408
commit
62edb8e04c
8 changed files with 974 additions and 28 deletions
|
|
@ -7,7 +7,10 @@ extends RefCounted
|
|||
## game/LAYOUT.md), and the zone banner.
|
||||
|
||||
const RUN_SPEED := 5.0 # PlayerCharacter.run_speed
|
||||
const MAX_TRAVEL := 12.0
|
||||
## #13: the two new south-west crop fields are a legitimate corner of the map (user-decided
|
||||
## placement), and the farthest pair (a new field to the Scrap Heap, clear across the map) is a
|
||||
## little past the old 12 s bar; raised to fit it with a little room.
|
||||
const MAX_TRAVEL := 13.0
|
||||
const ENEMY_RADIUS := 0.35
|
||||
const SCARECROW_RADIUS := 0.4
|
||||
const CELL := 0.5
|
||||
|
|
@ -42,10 +45,12 @@ func run(r: GameTestRunner) -> void:
|
|||
|
||||
func _zones(r: GameTestRunner, zones: FarmZones) -> void:
|
||||
var all := zones.zones()
|
||||
r.check(all.size() == FarmZone.Kind.size(), "one zone per kind (%d zones)" % all.size())
|
||||
# #13: two more CROP_FIELD zones (lettuce/cabbage, corn), so it's no longer one zone per kind.
|
||||
r.check(all.size() == FarmZone.Kind.size() + 2, "every kind has a zone, plus 2 more crop fields (%d zones)" % all.size())
|
||||
for kind: FarmZone.Kind in FarmZone.Kind.values():
|
||||
var z := zones.zone(kind)
|
||||
r.check(z != null and z.display_name != "", "zone %s exists and has a name" % FarmZone.Kind.keys()[kind])
|
||||
r.check(zones.zones_of(FarmZone.Kind.CROP_FIELD).size() == 3, "3 crop fields: the original, lettuce/cabbage, and corn")
|
||||
for i in all.size():
|
||||
var a := all[i]
|
||||
r.check(zones.playable.encloses(a.rect()), "%s lies inside the playable map" % a.display_name)
|
||||
|
|
@ -55,22 +60,37 @@ func _zones(r: GameTestRunner, zones: FarmZones) -> void:
|
|||
r.check(zones.zone_at(Vector3(8.0, 0.0, -10.0)) == null, "open ground between zones belongs to no zone")
|
||||
|
||||
|
||||
## #13: 20 more crop units in two later-sprouting fields (lettuce/cabbage, corn), 10 each, ids
|
||||
## 31..40 and 41..50, continuing the original field's plot numbering (7..10). GameConfig.start_crops
|
||||
## (30) only counts the original, always-grown field; the later fields grow FarmState.crops_total
|
||||
## when they sprout (LootSystem), so it's not part of this static count.
|
||||
func _crops(r: GameTestRunner, zones: FarmZones) -> void:
|
||||
var cfg := load("res://game/resources/game_config.tres") as GameConfig
|
||||
var units := zones.crop_units()
|
||||
var field := zones.zone(FarmZone.Kind.CROP_FIELD)
|
||||
r.check(units.size() == cfg.start_crops, "%d crop units, matching GameConfig.start_crops (%d)" % [units.size(), cfg.start_crops])
|
||||
var fields := zones.zones_of(FarmZone.Kind.CROP_FIELD)
|
||||
r.check(units.size() == cfg.start_crops + 20, "%d crop units: %d in the original field, 20 in the two later ones" % [units.size(), cfg.start_crops])
|
||||
var ids := {}
|
||||
var per_plot := {}
|
||||
var fewest := 1 << 30
|
||||
var by_crop := {} # crop name -> {sprout_night, count}
|
||||
for u in units:
|
||||
ids[u.unit_id] = true
|
||||
per_plot[u.plot] = int(per_plot.get(u.plot, 0)) + 1
|
||||
fewest = mini(fewest, u.get_child_count())
|
||||
r.check(field.contains(u.global_position), "crop unit %d lies in the crop field" % u.unit_id)
|
||||
r.check(fields.any(func(z: FarmZone) -> bool: return z.contains(u.global_position)), "crop unit %d lies in a crop field" % u.unit_id)
|
||||
var g: Dictionary = by_crop.get(u.crop, {"sprout_night": u.sprout_night, "count": 0})
|
||||
r.check(g["sprout_night"] == u.sprout_night, "every %s unit shares one sprout_night" % u.crop)
|
||||
g["count"] = int(g["count"]) + 1
|
||||
by_crop[u.crop] = g
|
||||
r.check(ids.size() == units.size() and ids.has(1) and ids.has(units.size()), "crop unit ids are unique, 1..%d" % units.size())
|
||||
r.check(per_plot.size() == 6 and per_plot.values().all(func(n: int) -> bool: return n == 5), "6 plots of 5 units (%s)" % [per_plot])
|
||||
r.check(per_plot.size() == 10 and per_plot.values().all(func(n: int) -> bool: return n == 5), "10 plots of 5 units (%s)" % [per_plot])
|
||||
r.check(fewest >= 8, "every unit is a visible cluster (fewest plants: %d)" % fewest)
|
||||
r.check(by_crop.get("sunflower", {}).get("count", 0) == cfg.start_crops and by_crop["sunflower"]["sprout_night"] == 0,
|
||||
"the original field's %d units are sunflowers, already grown" % cfg.start_crops)
|
||||
r.check(by_crop.get("lettuce", {}).get("count", 0) == 10 and by_crop["lettuce"]["sprout_night"] == 2,
|
||||
"10 lettuce/cabbage units sprout after night 2")
|
||||
r.check(by_crop.get("corn", {}).get("count", 0) == 10 and by_crop["corn"]["sprout_night"] == 4,
|
||||
"10 corn units sprout after night 4")
|
||||
|
||||
|
||||
func _markers(r: GameTestRunner, zones: FarmZones) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue