public static int D(int dice, int rolls, DiceModes mode) { if (mode == DiceModes.Min) { return(Dice.Min(dice, rolls)); } else if (mode == DiceModes.Max) { return(Dice.Max(dice, rolls)); } else { return(Dice.Sum(dice, rolls)); } }
public static int CalcDamage(ShootingParams shootingParams, int damageValue, int damageDice, DiceModes mode) { int totalDamage = 0; for (int i = 0; i < damageValue; i++) { int damage = damageDice != 0 ? Dice.D(damageDice, 1, mode) : damageValue; if (shootingParams.DamageRerolls == 0) { totalDamage += damage; continue; } float threshold = 100.0f * damage / damageDice; if (threshold < shootingParams.PercentToRerollDamage && shootingParams.DamageRerolls > 0) { shootingParams.DamageRerolls--; damage = damageDice != 0 ? Dice.D(damageDice, 1, mode) : damageValue; totalDamage += damage; } } return(totalDamage); }