export class DnDCharacter {
  public static generateAbilityScore(): number {
    return DnDCharacter.randomInt(3, 18)
  }

  public static getModifierFor(abilityValue: number): number {
    return Math.floor((abilityValue - 10) / 2)
  }

  public strength: number;
  public dexterity: number;
  public constitution: number;
  public intelligence: number;
  public wisdom: number;
  public charisma: number;
  public hitpoints: number;

  public constructor() {
    this.strength = DnDCharacter.generateAbilityScore()
    this.dexterity = DnDCharacter.generateAbilityScore()
    this.constitution = DnDCharacter.generateAbilityScore()
    this.intelligence = DnDCharacter.generateAbilityScore()
    this.wisdom = DnDCharacter.generateAbilityScore()
    this.charisma = DnDCharacter.generateAbilityScore()
    this.hitpoints = 10 + DnDCharacter.getModifierFor(this.charisma)
  }


  /**
   * randomNumber returns a random number between min and max (inclusive)
   */
  private static randomInt(min: number, max: number) {
    return Math.floor((Math.random()) * (max - min + 1)) + min;
  }
}

export class DnDCharacter {
  public static generateAbilityScore(): number {
    return DnDCharacter.randomInt(3, 18)
  }

  public static getModifierFor(abilityValue: number): number {
    return Math.floor((abilityValue - 10) / 2)
  }

  public strength: number;
  public dexterity: number;
  public constitution: number;
  public intelligence: number;
  public wisdom: number;
  public charisma: number;
  public hitpoints: number;

  public constructor() {
    this.strength = DnDCharacter.generateAbilityScore()
    this.dexterity = DnDCharacter.generateAbilityScore()
    this.constitution = DnDCharacter.generateAbilityScore()
    this.intelligence = DnDCharacter.generateAbilityScore()
    this.wisdom = DnDCharacter.generateAbilityScore()
    this.charisma = DnDCharacter.generateAbilityScore()
    this.hitpoints = 10 + DnDCharacter.getModifierFor(this.constitution)
  }


  /**
   * randomNumber returns a random number between min and max (inclusive)
   */
  private static randomInt(min: number, max: number) {
    return Math.floor((Math.random()) * (max - min + 1)) + min;
  }
}

Fix bug: hitpoints depends on constitution
Fix bug: hitpoints depends on constitution
