Files
settled-reach/client/tests/test_atlas_overlays.gd
T
jpmschweitzerandClaude Opus 4.8 cfd5e18d0a feat(client): district morphology generation overlay in the Atlas (T-1046, D-226)
Client half — the cascade's district tier is now visible in the Atlas map.

- protocol.gd: decode the district_grid field from AtlasLayerResponse.
- atlas_viewer.gd: a gen_district ('MRPH') toggle in OVERLAY_DEFS + the
  district-grid generation state (set/get) + wire it from the Ready response.
- atlas_marker_overlay.gd: _draw_gen_district() paints the coarse cols×rows grid,
  each cell coloured by its MorphologyZone discriminant (D-239 §6, 17-zone
  palette), semi-transparent under the Layer-1 line overlays. Planetary map view
  (not the 2km on-demand districts — those are Phase 5 in-world).

gdUnit4 test: overlay registered + district grid round-trips through the viewer
and the protocol decode. Visual tuning of the palette can follow once eyeballed
in the running Atlas.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 12:55:59 +02:00

56 lines
1.9 KiB
GDScript

## Tests for the Phase-4 generation overlays in the Atlas viewer (#960, D-225).
## Referencing AtlasViewer forces both it and AtlasMarkerOverlay to compile, so
## this also guards against parse errors in the overlay rendering code.
class_name TestAtlasOverlays
extends GdUnitTestSuite
func test_generation_overlays_registered() -> void:
var ids: Array = []
for d: Dictionary in AtlasViewer.OVERLAY_DEFS:
ids.append(d["id"])
assert_that(ids).contains(
["gen_l1_rivers", "gen_l1_basins", "gen_l1_attractors", "gen_district"]
)
## T-1046: the district/morphology grid round-trips through the viewer and the
## protocol decode surfaces it; referencing AtlasMarkerOverlay compiles the draw.
func test_district_grid_round_trips() -> void:
var v: AtlasViewer = auto_free(AtlasViewer.new())
assert_that(v.get_generation_district_grid()).is_null()
var grid := {
"cols": 2,
"rows": 1,
"morphology": PackedByteArray([8, 14]),
"elev_q": PackedByteArray([10, 90]),
}
v.set_generation_district_grid(grid)
assert_that(v.get_generation_district_grid()).is_equal(grid)
# The decoded response dict carries the district_grid key (protocol.gd, T-1046).
var decoded: Variant = Protocol.atlas_response_from_raw(
{"body_id": "GJ1c", "status": "Ready", "district_grid": grid}
)
assert_that((decoded as Dictionary).get("district_grid")).is_equal(grid)
func test_generation_data_round_trips() -> void:
var v: AtlasViewer = auto_free(AtlasViewer.new())
assert_that(v.get_generation_layer1()).is_null()
var mock := {
"body_id": "GJ1c",
"river_network": {"river_cells": [], "confluences": [], "mouths": []},
"drainage_basins": [],
"attractors": [],
}
v.set_generation_layer1(mock)
assert_that(v.get_generation_layer1()).is_equal(mock)
func test_implant_pending_start_stop() -> void:
var p: ImplantPending = auto_free(ImplantPending.new())
p.start("GENERATING LAYER 1")
assert_bool(p.visible).is_true()
p.stop()
assert_bool(p.visible).is_false()