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

export class RollTypeReveResistance extends RollType {
  get code() { return ROLL_TYPE_REVE_RESISTANCE }
  get name() { return `fait un jet de résistance` }
  get icon() { return `systems/foundryvtt-reve-de-dragon/assets/ui/resistance.svg` }
  get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-reve-resistance.hbs` }

  title(rollData) {
    return this.name
  }

  setRollDataType(rollData) {
    foundry.utils.mergeObject(rollData, {
      selected: {
        carac: { key: CARACS.REVE_ACTUEL, forced: true },
        diff: { value: -8, type: DIFF.LIBRE },
        comp: { key: '', forced: true },
        conditions: { hide: true }
      }
    })
    super.setRollDataType(rollData)
  }

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

}