jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

17 lines
646 B

'use strict';
module.exports = (match, numdice, numsides, operator, modifier) => {
numdice = parseInt(numdice);
numsides = parseInt(numsides);
let sum = (Math.floor(Math.random() * numsides) + 1) * numdice;
if (modifier && operator) {
modifier = parseInt(modifier);
//do i need to make sure it doesnt go negative or maybe give absolute value?
if (operator === '+') {
sum += modifier;
} else {
sum -= modifier;
}
}
return `<img src='/file/dice.png' height='16' width='16' /><span class='dice'>(${match}) Rolled ${numdice} dice with ${numsides} sides${modifier ? ' and modifier '+operator+modifier : '' } = ${sum}</span>`;
}