diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/P72CharacterWalkTests.fs')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/P72CharacterWalkTests.fs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/P72CharacterWalkTests.fs b/src/LivingVillage.Desktop.Tests/P72CharacterWalkTests.fs new file mode 100644 index 0000000..781d22c --- /dev/null +++ b/src/LivingVillage.Desktop.Tests/P72CharacterWalkTests.fs @@ -0,0 +1,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) |
