mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +02:00
20 lines
627 B
TypeScript
20 lines
627 B
TypeScript
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;
|
|
}
|