summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests/P62EvidenceTests.fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/P62EvidenceTests.fs')
-rw-r--r--src/LivingVillage.Desktop.Tests/P62EvidenceTests.fs52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/P62EvidenceTests.fs b/src/LivingVillage.Desktop.Tests/P62EvidenceTests.fs
new file mode 100644
index 0000000..630b897
--- /dev/null
+++ b/src/LivingVillage.Desktop.Tests/P62EvidenceTests.fs
@@ -0,0 +1,52 @@
+namespace LivingVillage.Desktop.Tests
+
+open Microsoft.VisualStudio.TestTools.UnitTesting
+open LivingVillage.Kernel
+open LivingVillage.Kernel.Sim
+open LivingVillage.Desktop
+open LivingVillage.Desktop.VillagePresentation
+
+/// P62(G2 整改):样板村落「全貌俯瞰 / 民居内景」两帧取证的可复现约束。
+/// 1) 内景必须是真实 Interact 进门路径可达(HomeMode → Inside)。
+/// 2) 俯瞰必须让样板村落全部元素落在真实相机视口内(相机随角色居中,无缩尺)。
+[<TestClass>]
+type P62EvidenceTests () =
+
+ let tileCenter (t: TilePosition) : Vec2 =
+ { X = float32 (t.X * Sim.tilePixels + Sim.tilePixels / 2)
+ Y = float32 (t.Y * Sim.tilePixels + Sim.tilePixels / 2) }
+
+ let sampleDoor () : TilePosition =
+ (VillagePresentation.scene.Homes |> List.head).Door
+
+ /// 把角色放到样板民居门口,用真实 M5Command.Interact 进门,断言进入内景模式。
+ [<TestMethod>]
+ member _.InteriorEntryViaRealInteractReachesInsideMode () =
+ let doorCenter = tileCenter (worldTileForSceneTile (sampleDoor ()))
+ let base_ = Sim.initialWorldN 42UL Sim.npcCount
+ let world = { base_ with Avatar = { base_.Avatar with Pos = doorCenter } }
+ let _, view = M5Interaction.apply M5Command.Interact world M5Interaction.initial
+ Assert.IsTrue(view.Status = "home entered", sprintf "真实 Interact 未从门口进入内景:%s" view.Status)
+ match view.HomeMode with
+ | Inside (HomeId 1) -> ()
+ | other -> Assert.Fail(sprintf "内景模式应为 Inside(HomeId 1),实际 %A" other)
+
+ /// 俯瞰点(scene (6,3))居中时,样板村落全部元素 + 民居门口都应在 1280x720 真实视口内。
+ [<TestMethod>]
+ member _.OverviewViewportContainsWholeSampleVillage () =
+ let viewWidth = 1280.0f
+ let viewHeight = 720.0f
+ let worldWidth = float32 (Sim.mapWidthTiles * Sim.tilePixels)
+ let worldHeight = float32 (Sim.mapHeightTiles * Sim.tilePixels)
+ let vantage = tileCenter (worldTileForSceneTile { X = 6; Y = 3 })
+ let camX = max 0.0f (min (vantage.X - viewWidth / 2.0f) (worldWidth - viewWidth))
+ let camY = max 0.0f (min (vantage.Y - viewHeight / 2.0f) (worldHeight - viewHeight))
+ let targets =
+ VillagePresentation.scene.Elements
+ |> List.map (fun e -> e.Prop, tileCenter (worldTileForSceneTile e.Position))
+ |> fun xs -> (HomeDoor, tileCenter (worldTileForSceneTile (sampleDoor ()))) :: xs
+ for prop, center in targets do
+ let visible =
+ center.X >= camX && center.X <= camX + viewWidth
+ && center.Y >= camY && center.Y <= camY + viewHeight
+ Assert.IsTrue(visible, sprintf "俯瞰帧漏掉 %A @ tile(%.0f,%.0f)" prop center.X center.Y)