summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
-rw-r--r--src/LivingVillage.Desktop.Tests/MapGenTests.fs47
-rw-r--r--src/LivingVillage.Desktop.Tests/PrototypeTests.fs8
2 files changed, 51 insertions, 4 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
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
index a38228f..dd4e7b3 100644
--- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
+++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
@@ -1133,10 +1133,10 @@ type PrototypeTests () =
Assert.AreEqual<string list>([], missing, sprintf "Missing Jiangnan PNG assets: %s" (String.concat ", " missing))
- // The baked world atlas must match the 31-slot layout the renderer indexes into
+ // The baked world atlas must match the 32-slot layout the renderer indexes into
// (P17 added 石灯笼/水缸/摊贩摊位 as slots 25..27; P26 added the variant-B house
- // parts 屋檐挑出/木格栅窗/院门 as slots 28..30).
- Assert.AreEqual<int>(31, VillageArt.worldTileCount)
+ // parts 屋檐挑出/木格栅窗/院门 as slots 28..30 and 护岸石垒 as slot 31).
+ Assert.AreEqual<int>(32, VillageArt.worldTileCount)
let worldPath = Path.Combine(AppContext.BaseDirectory, "Assets/jiangnan-world.png")
let header = File.ReadAllBytes worldPath
let be32 offset =
@@ -1146,7 +1146,7 @@ type PrototypeTests () =
||| int header.[offset + 3]
let atlasWidth : int = be32 16
let atlasHeight : int = be32 20
- Assert.IsTrue((atlasWidth = VillageArt.worldAtlasWidth), "world atlas width must match 31 x 32px slots")
+ Assert.IsTrue((atlasWidth = VillageArt.worldAtlasWidth), "world atlas width must match 32 x 32px slots")
Assert.IsTrue((atlasHeight = VillageArt.worldAtlasHeight), "world atlas height must stay 32px")
[<TestMethod>]