mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: resolving lines
This commit is contained in:
1 parent
5372068830
commit
43e1d53d39
9 files changed
+149
-14
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { resolveAncestry } from './resolveAncestry';
|
||||
import { tankDefinitions } from './tankDefinitions';
|
||||
|
||||
export async function buildTechTreeLine(start: number, end: number) {
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const endTank = awaitedTankDefinitions[end];
|
||||
if (!endTank.ancestors) throw new Error('End tank has no ancestors');
|
||||
const line = [end];
|
||||
|
||||
if (start === end) return line;
|
||||
for (const ancestorId of endTank.ancestors) {
|
||||
if ((await resolveAncestry(ancestorId)).includes(start)) {
|
||||
line.push(...(await buildTechTreeLine(start, ancestorId)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
Reference in new issue
Block a user