interaction map type
This commit is contained in:
18
src/app/logic/random.service.ts
Normal file
18
src/app/logic/random.service.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user