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:
@@ -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']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user