// Library: Lodash/fp
import fp from "https://cdn.skypack.dev/lodash@4.17.21/fp";
const dice = fp.curry((phase, mod, times) => {
return new Array(times)
.fill(0)
.map(() => fp.random(1, phase))
.reduce((result, trial) => result + trial, mod || 0);
}, 2);
// n d 6 + 1
const d6Plus1 = dice(6, 1);
// 1 d 6 + 1
d6Plus1(1);
// 3 d 6 + 1
d6Plus1(3);