mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
10 lines
239 B
JavaScript
10 lines
239 B
JavaScript
|
|
module.exports = function crit (user, stat = 'str', chance = 0.03) {
|
|
let s = user._statsComputed[stat];
|
|
if (user.fns.predictableRandom() <= chance * (1 + s / 100)) {
|
|
return 1.5 + 4 * s / (s + 200);
|
|
} else {
|
|
return 1;
|
|
}
|
|
};
|