105 lines
3.1 KiB
JavaScript
105 lines
3.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
import {
|
|
parseWoWAnimationName,
|
|
selectCreatureRuntimeAnimations,
|
|
semanticCreatureAnimations,
|
|
} from "./runtime-creature-animations.mjs";
|
|
|
|
const clips = (names) => names.map((name) => ({
|
|
getName: () => name,
|
|
listChannels: () => [{}],
|
|
listSamplers: () => [{}],
|
|
}));
|
|
|
|
describe("creature runtime animation policy", () => {
|
|
it("keeps gameplay families and all variations of the selected combat family", () => {
|
|
const source = clips([
|
|
"EmoteDance (ID 69 variation 0)",
|
|
"Attack2HL (ID 19 variation 0)",
|
|
"AttackUnarmed (ID 16 variation 1)",
|
|
"Stand (ID 0 variation 0)",
|
|
"AttackUnarmed (ID 16 variation 0)",
|
|
"Walk (ID 4 variation 0)",
|
|
"Run (ID 5 variation 0)",
|
|
"SpellCastDirected (ID 53 variation 0)",
|
|
"CombatCritical (ID 10 variation 0)",
|
|
"Death (ID 1 variation 1)",
|
|
"Death (ID 1 variation 0)",
|
|
"Drown (ID 131 variation 0)",
|
|
]);
|
|
|
|
const selected = selectCreatureRuntimeAnimations(source);
|
|
|
|
assert.deepEqual(selected.retainedNames, [
|
|
"AttackUnarmed (ID 16 variation 1)",
|
|
"Stand (ID 0 variation 0)",
|
|
"AttackUnarmed (ID 16 variation 0)",
|
|
"Walk (ID 4 variation 0)",
|
|
"Run (ID 5 variation 0)",
|
|
"SpellCastDirected (ID 53 variation 0)",
|
|
"CombatCritical (ID 10 variation 0)",
|
|
"Death (ID 1 variation 1)",
|
|
"Death (ID 1 variation 0)",
|
|
]);
|
|
assert.deepEqual(selected.removedNames, [
|
|
"EmoteDance (ID 69 variation 0)",
|
|
"Attack2HL (ID 19 variation 0)",
|
|
"Drown (ID 131 variation 0)",
|
|
]);
|
|
assert.deepEqual(selected.groups.attack, [
|
|
"AttackUnarmed (ID 16 variation 0)",
|
|
"AttackUnarmed (ID 16 variation 1)",
|
|
]);
|
|
});
|
|
|
|
it("falls back to semantic clip names when native WoW ids are unavailable", () => {
|
|
const selected = selectCreatureRuntimeAnimations(clips([
|
|
"Idle - breathing",
|
|
"Walk - forward",
|
|
"Run - forward",
|
|
"Attack - claw01",
|
|
"Attack - claw02",
|
|
"Cast - spell01",
|
|
"Wound - hurt",
|
|
"Death - death",
|
|
"Emote - cheer",
|
|
]));
|
|
|
|
assert(!selected.retainedNames.includes("Emote - cheer"));
|
|
assert.equal(selected.groups.attack.length, 2);
|
|
assert.deepEqual(semanticCreatureAnimations(selected.retainedNames), {
|
|
stand: false,
|
|
walk: true,
|
|
run: true,
|
|
attack: true,
|
|
cast: true,
|
|
hit: true,
|
|
death: true,
|
|
});
|
|
});
|
|
|
|
it("parses wow.export ids and variations", () => {
|
|
assert.deepEqual(parseWoWAnimationName("Attack1H (ID 17 variation 2)"), {
|
|
label: "Attack1H",
|
|
id: 17,
|
|
variation: 2,
|
|
});
|
|
});
|
|
|
|
it("does not retain empty source placeholders", () => {
|
|
const source = clips([
|
|
"Stand (ID 0 variation 0)",
|
|
"SpellCastDirected (ID 53 variation 0)",
|
|
"SpellCastOmni (ID 54 variation 0)",
|
|
]);
|
|
source[1].listChannels = () => [];
|
|
source[1].listSamplers = () => [];
|
|
|
|
const selected = selectCreatureRuntimeAnimations(source);
|
|
|
|
assert.deepEqual(selected.groups.cast, ["SpellCastOmni (ID 54 variation 0)"]);
|
|
assert(selected.removedNames.includes("SpellCastDirected (ID 53 variation 0)"));
|
|
});
|
|
});
|