blob: 630b89732d9934cb08d568e7a61f5331e6996d70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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)
|