0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00
server/project/src/helpers/ProbabilityHelper.ts
TheSparta 418d9f2a8f Import path alias on the whole project (!157)
- Ability to use @spt-aki path alias on the whole project.
- Swapped all imports from relative paths, for imports using the path alias.

Reviewed-on: SPT-AKI/Server#157
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-19 17:21:17 +00:00

25 lines
740 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;
}
}