diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 10:14:31 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 10:14:31 +0800 |
| commit | b377e750a6a3f35c5d64a29f14ac3fbd87d4a752 (patch) | |
| tree | 8baac5fca38fdcecda4a00eed7a58b1031ab9dca /src/LivingVillage.Desktop.Tests/MapGenTests.fs | |
| parent | d36e86ac637ccc477479f88bea511c49b0a6a67c (diff) | |
| parent | 5f12e63f2d2203267c30666f1559e06ec637b91c (diff) | |
| download | living-village-b377e750a6a3f35c5d64a29f14ac3fbd87d4a752.tar.gz | |
merge: P26 美术整改(民居第二变体/河岸装饰/夜月光/HUD 双景可读)— Hermes 复验通过
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/MapGenTests.fs')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/MapGenTests.fs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/MapGenTests.fs b/src/LivingVillage.Desktop.Tests/MapGenTests.fs index f426a8a..6486dd7 100644 --- a/src/LivingVillage.Desktop.Tests/MapGenTests.fs +++ b/src/LivingVillage.Desktop.Tests/MapGenTests.fs @@ -298,6 +298,53 @@ type MapGenTests () = Assert.AreEqual<int64>(6042052L, checksum (MapGen.generateWithSize 64 48 (uint64 4242))) Assert.AreEqual<int64>(1284656962L, checksum (MapGen.generateWithSize 256 192 (uint64 4242))) + // ---- P26:河岸装饰(护岸石垒/芦苇/垂柳)仅大图、落在岸格且不挡通行 ---- + + [<TestMethod>] + member _.RiverDecorationsOnlyEnabledOnLargeMaps () = + Assert.IsFalse((MapGen.paramsForSize 64 48 (uint64 1)).RiverDecorations) + Assert.IsFalse((MapGen.paramsForSize 256 192 (uint64 1)).RiverDecorations) + Assert.IsTrue((MapGen.paramsForSize 512 384 (uint64 1)).RiverDecorations) + Assert.AreEqual<int>(0, (MapGen.generateWithSize 64 48 (uint64 4242)).Decorations.Length) + Assert.AreEqual<int>(0, (MapGen.generateWithSize 256 192 (uint64 4242)).Decorations.Length) + + [<TestMethod>] + member _.RiverbankDecorationsSitOnBanksAndNeverBlockPathsOrBridges () = + let map = MapGen.generateWithSize 512 384 (uint64 4242) + Assert.IsTrue(map.Decorations.Length > 0, "512x384 must place riverbank decorations") + let pathSet = System.Collections.Generic.HashSet<int>(map.Paths |> List.map (fun (x, y) -> y * map.Width + x)) + let bridgeSet = System.Collections.Generic.HashSet<int>(map.Bridges |> List.map (fun (x, y) -> y * map.Width + x)) + let water x y = map.Tiles.[y * map.Width + x] = int MapGen.GroundTile.Water + let inCore x y = x >= map.Core.MinX && x <= map.Core.MaxX && y >= map.Core.MinY && y <= map.Core.MaxY + for decoration in map.Decorations do + let footprint = + match decoration.Kind with + | MapGen.Willow -> [ decoration.Y; decoration.Y + 1 ] + | _ -> [ decoration.Y ] + for y in footprint do + let i = y * map.Width + decoration.X + Assert.AreNotEqual<int>(int MapGen.GroundTile.Water, map.Tiles.[i], "decoration must sit on land") + Assert.IsFalse(pathSet.Contains i, "decoration must not block a path tile") + Assert.IsFalse(bridgeSet.Contains i, "decoration must not block a bridge tile") + Assert.IsFalse(inCore decoration.X y, "decoration must stay outside the core") + // Bank adjacency: at least one footprint tile must touch the river orthogonally. + let touchesWater = + footprint + |> List.exists (fun y -> + [ (decoration.X + 1, y); (decoration.X - 1, y); (decoration.X, y + 1); (decoration.X, y - 1) ] + |> List.exists (fun (nx, ny) -> + nx >= 0 && nx < map.Width && ny >= 0 && ny < map.Height && water nx ny)) + Assert.IsTrue(touchesWater, "decoration must line the riverbank, not float inland") + + [<TestMethod>] + member _.LargeMapRiverDecorationsAreDeterministic () = + let a = MapGen.generateWithSize 512 384 (uint64 4242) + let b = MapGen.generateWithSize 512 384 (uint64 4242) + Assert.IsTrue(a.Decorations = b.Decorations) + Assert.AreEqual<string>(MapGen.serialize a, MapGen.serialize b) + let c = MapGen.generateWithSize 512 384 (uint64 7) + Assert.AreNotEqual<string>(MapGen.serialize a, MapGen.serialize c) + [<TestMethod>] member _.VisibleRangeClampsAtLegacyMapEdges () = let x0, y0, x1, y1 = MapGen.visibleTileRange 64 48 0 0 2048 1536 |
