Begin implementation of the Stats / Skills tab
This commit is contained in:
parent
753d72b4e0
commit
0e8d1615a7
16 changed files with 292 additions and 64 deletions
18
module/utils/modifierToString.mjs
Normal file
18
module/utils/modifierToString.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Takes in an integer and converts it into a string format that can be used in
|
||||
* roll formulas or for displaying to the user.
|
||||
*
|
||||
* @param {number} mod The modifier to stringify
|
||||
* @param {object} opts
|
||||
* @param {boolean} opts.spaces Puts spaces on either side of the operand
|
||||
* @returns {string}
|
||||
*/
|
||||
export function modifierToString(mod, opts = {}) {
|
||||
if (mod == 0) return ``;
|
||||
|
||||
let value = [``, `+`, mod]
|
||||
if (mod < 0) {
|
||||
value = [``, `-`, Math.abs(mod)]
|
||||
};
|
||||
return value.join(opts.spaces ? ` ` : ``);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue