Files
forgotten-friends/src/app/logic/random.service.ts
2026-03-15 13:10:13 +01:00

18 lines
484 B
TypeScript

import { Injectable } from "@angular/core";
@Injectable({ providedIn: 'root' })
export class RandomService {
private rollRandom(min: number, max: number): number {
return Math.floor(Math.random() * (max - min) + min);
}
public matchesChance(chance: number, max: number): boolean {
const random = this.rollRandom(0, max);
console.log(random, chance);
if (random < chance) {
return true;
}
return false;
}
}