Files
playground-frontend/src/app/shared/SharedFunctions.ts
T
lobo e8354bfecd
Build, Test & Push Frontend / quality-check (pull_request) Successful in 1m10s
Build, Test & Push Frontend / docker (pull_request) Has been skipped
Add Prim/Kruskal maze gen & nodeData refactor
Implement Prim and Kruskal maze generation in the Labyrinth component with animated generation and UI guards. Introduces isAnimationRunning signal, mazeAnimationSpeed, maze node order tracking and animateMazeGeneration; createRandom(now takes a boolean) triggers either Prim or Kruskal flow, sets random start/end, and animates. Refactor Node.distance -> nodeData across models, components and the PathfindingService (Dijkstra/A*) to use nodeData for g-scores/ids. Add SharedFunctions.shuffleArray utility and update i18n (EN/DE) with labels for Prim/Kruskal. Misc: minor cleanup/init changes and drawing logic adjustments to support the new maze flows.
2026-02-09 14:55:05 +01:00

26 lines
717 B
TypeScript

export class SharedFunctions {
static openMail(event?: Event) {
event?.preventDefault();
const user = 'andreas.dahm';
const domain = 'gmail.com';
globalThis.location.href = `mailto:${user}@${domain}`;
}
static randomIntFromInterval(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1) + min);
}
static randomEventIntFromInterval(interval: number): number {
return Math.floor(Math.random() * (interval / 2)) * 2;
}
static shuffleArray<T>(array: T[]): T[] {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
}