export function d100() {
  return Math.floor(Math.random() * 100) + 1;
}

export function degrees(target, roll) {
  const success = roll <= target;
  if (success) {
    return { success, dos: 1 + Math.floor((target - roll) / 10), dof: 0 };
  }
  return { success, dos: 0, dof: 1 + Math.floor((roll - target) / 10) };
}

export function clampTarget(value) {
  return Math.max(0, Math.min(100, Number(value) || 0));
}

export const MISSION_ROLL_CONTEXT_KEY = 'dw:mission:rollContext';
