blob: 781d22cfbd7838cd6270305827af6f4851687abb (
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
|
namespace LivingVillage.Desktop.Tests
open Microsoft.VisualStudio.TestTools.UnitTesting
open LivingVillage.Desktop
/// P72 回归:角色行走帧表完整性——四向各 8 格(6 走 + 2 待机),
/// 六张行走帧两两可见区分(含左右过渡步),且与待机帧不同。
[<TestClass>]
type P72CharacterWalkTests () =
let letters variant direction frame = CharacterArt.frameLetters variant direction frame
let cellDiff (a: string list) (b: string list) : int =
List.zip a b
|> List.sumBy (fun (ra, rb) -> Seq.zip ra rb |> Seq.filter (fun (x, y) -> x <> y) |> Seq.length)
[<TestMethod>]
member _.WalkFrameTableHasSixDistinctPosesPerDirection () =
Assert.AreEqual<int>(8, CharacterArt.frameCount)
Assert.AreEqual<int>(6, CharacterArt.walkFrameCount)
Assert.AreEqual<int>(2, CharacterArt.idleFrameCount)
for variant in 0 .. CharacterArt.variantCount - 1 do
for direction in 0 .. CharacterArt.directionCount - 1 do
let walk = [ 0 .. CharacterArt.walkFrameCount - 1 ] |> List.map (letters variant direction)
// 6 张行走帧两两必须有可见差异(不允许重复姿态)。
for i in 0 .. walk.Length - 1 do
for j in i + 1 .. walk.Length - 1 do
Assert.IsTrue(
cellDiff walk.[i] walk.[j] >= 4,
sprintf "v%d d%d 走帧 %d 与 %d 姿态重复" variant direction i j)
// 行走与待机必须不同。
let idle = letters variant direction CharacterArt.walkFrameCount
Assert.IsTrue(cellDiff walk.[0] idle >= 4, "行走帧与待机帧相同")
[<TestMethod>]
member _.AtlasStridePlacesSixWalkThenTwoIdleCells () =
Assert.AreEqual<int>(5120, CharacterArt.atlasWidth)
Assert.AreEqual<int>(5120, VillageArt.characterAtlasWidth)
let stride = VillageArt.characterAtlasWidth / 32 / (5 * 4)
Assert.AreEqual<int>(8, stride)
|