import { Apprecier } from "../moral/apprecier.mjs"
import { DIFF, ROLL_TYPE_OEUVRE } from "./roll-constants.mjs"
import { PART_OEUVRE } from "./roll-part-oeuvre.mjs"
import { RollType } from "./roll-type.mjs"

export class RollTypeOeuvre extends RollType {
  get code() { return ROLL_TYPE_OEUVRE }
  get name() { return `Interpréter une oeuvre` }

  visible(rollData) { return rollData.active.actor.isPersonnage() }
  title(rollData) {
    const current = rollData.current[PART_OEUVRE]
    if (current.art) {
      return `${current.art.action} ${current.label}`
    }
    return 'interprête une oeuvre'
  }

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

  getResult(rollData, impacts) {
    const current = rollData.current[PART_OEUVRE]
    return Apprecier.getAppreciation(current.qualite, current.oeuvre, rollData, current.comp)
  }
}

