feat(extract): build containment tree and traverse all containers

Add buildTree to mirror how TTS nests objects, with a display label
(Nickname or class Name). Generalize traverseMod to descend into any
object with ContainedObjects, not just bags, and add Nickname to
TTSObject.
This commit is contained in:
2026-08-08 12:19:39 +08:00
parent e2d87df1a4
commit d8a698986a
5 changed files with 75 additions and 12 deletions
+9 -3
View File
@@ -43,9 +43,9 @@ describe('markParent', () => {
});
describe('traverseMod', () => {
it('yields every non-bag object in order', () => {
it('yields every object including containers, in order', () => {
const guids = [...traverseMod(mod)].map((o) => o.GUID);
expect(guids).toEqual(['a', 'c', 'e', 'f']);
expect(guids).toEqual(['a', 'b', 'c', 'd', 'e', 'f']);
});
it('descends into nested bags', () => {
@@ -53,8 +53,14 @@ describe('traverseMod', () => {
expect(guids).toContain('e');
});
it('descends into any object with ContainedObjects', () => {
const custom = { Name: 'Custom_Model', GUID: 'x', Description: '', ContainedObjects: [card('y')] };
const guids = [...traverseMod(custom)].map((o) => o.GUID);
expect(guids).toEqual(['x', 'y']);
});
it('accepts a single object', () => {
const guids = [...traverseMod(bag('b', [card('c')]))].map((o) => o.GUID);
expect(guids).toEqual(['c']);
expect(guids).toEqual(['b', 'c']);
});
});