UNPKG

@randsum/root-rpg

Version:

A flexible, type-safe dice roller for the Root RPG system

4 lines (2 loc) 1.05 kB
var g=require("node:module");var{defineProperty:l,getOwnPropertyNames:u,getOwnPropertyDescriptor:n}=Object,m=Object.prototype.hasOwnProperty;var R=new WeakMap,f=(t)=>{var o=R.get(t),e;if(o)return o;if(o=l({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")u(t).map((r)=>!m.call(o,r)&&l(o,r,{get:()=>t[r],enumerable:!(e=n(t,r))||e.enumerable}));return R.set(t,o),o};var a=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0,configurable:!0,set:(r)=>o[e]=()=>r})};var c={};a(c,{rollRootRpg:()=>s});module.exports=f(c);var p=require("@randsum/roller");function i(t){switch(!0){case t>=10:return"Strong Hit";case(t>=7&&t<=9):return"Weak Hit";default:return"Miss"}}function s(t){if(!Number.isFinite(t))throw new Error(`Root RPG bonus must be a finite number, received: ${t}`);if(t<-20||t>20)throw new Error(`Root RPG bonus is outside reasonable range (-20 to +20), received: ${t}`);let o=p.roll({quantity:2,sides:6,modifiers:{plus:t}});return{...o,result:{hit:i(o.total),total:o.total}}} //# debugId=8B881FB7C5BE41A764756E2164756E21