Files
shadow-over-bishkek001/dialogEditor/src/utils/idGen.ts
T

15 lines
407 B
TypeScript

import { NodeType } from '../types/dialogue';
export function makeNodeId(type: NodeType, existingIds: Set<string>): string {
const base = type.toLowerCase();
let n = 1;
while (existingIds.has(`${base}_${n}`)) n++;
return `${base}_${n}`;
}
export function makeDialogueId(existingIds: Set<string>): string {
let n = 1;
while (existingIds.has(`dialog_new${n}`)) n++;
return `dialog_new${n}`;
}