import { RdDCarac } from "../rdd-carac.js"
import { RollPartCheckbox } from "./roll-part-checkbox.mjs"

const ETAT = "etat"

export class RollPartEtat extends RollPartCheckbox {

  get code() { return ETAT }

  visible(rollData) {
    const selectedCarac = rollData.current.carac?.key ?? ''
    if (selectedCarac == '') {
      return false
    }
    if (RdDCarac.isChance(selectedCarac)) {
      return false
    }
    if (RdDCarac.isReve(selectedCarac)) {
      if ((rollData.current.comp?.key ?? '') == '') {
        return false
      }
    }
    return this.getCheckboxValue(rollData) != 0
  }

  getCheckboxLabel(rollData) { return "État général" }
  getCheckboxValue(rollData) {
    return rollData.active.actor.getEtatGeneral({ ethylisme: true })
  }
}
