using Core.Annotations; using Core.Models.Utils; using Core.Utils; namespace Core.Helpers; [Injectable] public class ProbabilityHelper { private readonly ISptLogger _logger; private readonly RandomUtil _randomUtil; public ProbabilityHelper ( ISptLogger logger, RandomUtil randomUtil ) { _logger = logger; _randomUtil = randomUtil; } /// /// Chance to roll a number out of 100 /// /// Percentage chance roll should success /// scale of chance to allow support of numbers > 1-100 /// true if success public bool RollChance(double chance, double scale = 1) { return _randomUtil.GetInt(1, (int)(100 * scale)) / (1 * scale) <= chance; } }