mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
12 lines
335 B
JavaScript
12 lines
335 B
JavaScript
import predictableRandom from './predictableRandom';
|
|
import statsComputed from '../libs/statsComputed';
|
|
|
|
function crit (user, stat = 'str', chance = 0.03) {
|
|
const s = statsComputed(user)[stat];
|
|
if (predictableRandom(user) <= chance * (1 + s / 100)) {
|
|
return 1.5 + 4 * s / (s + 200);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
export default { crit };
|