const MODIFIER_TABLE: [number, number][] = [
  [3, -4],
  [5, -3],
  [7, -2],
  [9, -1],
  [11, 0],
  [13, 1],
  [15, 2],
  [17, 3],
  [18, 4],
];

export function getModifier(score: number): number {
  for (const [max, mod] of MODIFIER_TABLE) {
    if (score <= max) return mod;
  }
  return 4;
}

export function formatModifier(mod: number): string {
  return mod >= 0 ? `+${mod}` : `${mod}`;
}
