Files
buzz-sheet/lib/guides/talents.ts
T
gunshiz 8177c91434
CI / Verify (push) Successful in 50s
CI / Build immutable images and deploy (push) Successful in 4m15s
feat : update
2026-08-30 11:17:58 +00:00

44 lines
1.4 KiB
TypeScript

export type TalentRelation = "gt" | "gte";
export interface TalentPriority {
type: "NA" | "E" | "Q";
priority: number;
level?: string;
relationToNext?: TalentRelation;
}
export function normalizeTalentPriorities(talents: readonly TalentPriority[]): TalentPriority[] {
const ordered = [...talents].sort((a, b) => a.priority - b.priority);
return ordered.map((talent, index) => ({
...talent,
priority: index + 1,
relationToNext: index < ordered.length - 1 ? talent.relationToNext ?? "gt" : undefined,
}));
}
export function reorderTalentPriorities(
talents: readonly TalentPriority[],
activeType: TalentPriority["type"],
overType: TalentPriority["type"],
): TalentPriority[] {
const ordered = normalizeTalentPriorities(talents);
const from = ordered.findIndex((talent) => talent.type === activeType);
const to = ordered.findIndex((talent) => talent.type === overType);
if (from < 0 || to < 0 || from === to) return ordered;
const relations = ordered.slice(0, -1).map((talent) => talent.relationToNext ?? "gt");
const next = [...ordered];
const [moved] = next.splice(from, 1);
next.splice(to, 0, moved);
return next.map((talent, index) => ({
...talent,
priority: index + 1,
relationToNext: index < next.length - 1 ? relations[index] : undefined,
}));
}
export function talentRelationSymbol(relation?: TalentRelation): ">" | "≥" {
return relation === "gte" ? "≥" : ">";
}