import { CARACS } from "../rdd-carac.js"
import { DIFF, ROLL_TYPE_APPEL_CHANCE } from "./roll-constants.mjs"
import { RollType } from "./roll-type.mjs"

export class RollTypeAppelChance extends RollType {
  get code() { return ROLL_TYPE_APPEL_CHANCE }
  get name() { return `fait appel à la chance` }
  get icon() { return `systems/foundryvtt-reve-de-dragon/assets/ui/chance.svg` }
  get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-appel-chance.hbs` }

  title(rollData) {
    return this.name
  }

  setRollDataType(rollData) {
    foundry.utils.mergeObject(rollData, {
      selected: {
        carac: { key: CARACS.CHANCE_ACTUELLE, forced: true },
        diff: { value: 0, type: '' },
        comp: { key: '', forced: true },
        conditions: { hide: true }
      }
    })
    super.setRollDataType(rollData)
  }

  onSelect(rollData) {
    this.setDiffType(rollData, DIFF.AUCUN)
  }

}