This commit is contained in:
Forrest 2026-10-04 12:07:36 -04:00
parent 276d43613d
commit 4298caf5cb
552 changed files with 42990 additions and 776 deletions

View file

@ -7,11 +7,33 @@ extends SceneTree
const SUITES := [
"res://game/tests/test_farm_state.gd",
"res://game/tests/test_save.gd",
"res://game/tests/test_outcome.gd",
"res://game/tests/test_campaign.gd",
"res://game/tests/test_farm_layout.gd",
"res://game/tests/test_theft.gd",
"res://game/tests/test_scarecrow.gd",
"res://game/tests/test_weapons.gd",
"res://game/tests/test_economy.gd",
"res://game/tests/test_structures.gd",
"res://game/tests/test_targets.gd",
"res://game/tests/test_roster.gd",
"res://game/tests/test_nights.gd",
"res://game/tests/test_cycle.gd",
"res://game/tests/test_flow.gd",
"res://game/tests/test_coop.gd",
]
const TICK := 1.0 / 60.0
## Points on the farm's edge (FarmZones.edge) for tests that send an enemy in from a known side:
## on foot GameConfig.spawn_margin (3 m) outside the map, where the perimeter gaps used to be...
const EDGE := {
"north": Vector2(12.0, -48.0), "driveway": Vector2(50.0, -39.5), "east": Vector2(50.0, -18.5),
"south-east": Vector2(31.0, 18.0), "south-west": Vector2(-4.0, 18.0), "west": Vector2(-16.0, -6.0),
}
## ...and flying flyer_spawn_margin (8 m) out, where the crow approaches were.
const SKY := {
"north": Vector2(17.0, -53.0), "east": Vector2(55.0, -5.0), "south": Vector2(17.0, 23.0), "west": Vector2(-21.0, -15.0),
}
var passes: int = 0
var failures: int = 0
@ -37,6 +59,11 @@ func _main() -> void:
var suite: Object = (load(path) as GDScript).new()
await suite.call("run", self)
print("TESTS: %d checks passed, %d failed (%.1f s)" % [passes, failures, (Time.get_ticks_msec() - t0) / 1000.0])
# Free whatever suites left behind and give the audio server a mix to drop stopped sounds.
for c in root.get_children():
c.queue_free()
await process_frame
await create_timer(0.25).timeout
quit(mini(failures, 125))
@ -61,6 +88,15 @@ func make_campaign(cfg: GameConfig = null) -> CampaignController:
return c
## Marks the next n crop units that are still on the farm as lost.
static func lose_crops(s: FarmState, n: int) -> void:
var id := 1
while n > 0 and id <= s.crops_total:
if s.lose_crop(id):
n -= 1
id += 1
## Ticks at 60 Hz until the phase changes; returns the game seconds that took (INF if it
## never changed within max_seconds).
static func run_phase(c: CampaignController, max_seconds: float = 1000.0) -> float: