Server/project/src/helpers/ProbabilityHelper.ts
Refringe 50c7a26a58
ESLint Pass
This is the first pass of ESLint on the codebase.

ESLint formatting is less strict when it comes to line-length and line-breaks then dprint/biome, so if you see formatting that you don't like... fix it! It shouldn't require a configuration change.

- This should merge clean into master (when the time comes).
- This will not merge clean into `3.9.0-DEV`, but the conflicts aren't that bad.
2024-05-07 23:57:08 -04:00

25 lines
739 B
TypeScript

import { inject, injectable } from "tsyringe";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
@injectable()
export class ProbabilityHelper
{
constructor(
@inject("WinstonLogger") protected logger: ILogger,
@inject("RandomUtil") protected randomUtil: RandomUtil,
)
{}
/**
* Chance to roll a number out of 100
* @param chance Percentage chance roll should success
* @param scale scale of chance to allow support of numbers > 1-100
* @returns true if success
*/
public rollChance(chance: number, scale = 1): boolean
{
return this.randomUtil.getInt(1, 100 * scale) / (1 * scale) <= chance;
}
}