import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs";

export const PART_APPRECIER = "apprecier"

export class RollPartApprecier extends RollPart {

  get code() { return PART_APPRECIER }
  get section() { return ROLLDIALOG_SECTION.CHOIX }

  restore(rollData) {
    this.setCurrent(rollData, this.getSaved(rollData))
  }

  store(rollData, targetData) {
    this.setSaved(targetData, this.getCurrent(rollData))
  }

  visible(rollData) {
    return rollData.type.appreciation
  }

  getAjustements(rollData) {
    const current = this.getCurrent(rollData)
    if (current.appreciation.jetQualite){
      return [{
        label: 'Qualité',
        value: Math.abs(current.qualite)
      }]
    }
    return []
  }
}