// SPDX-FileCopyrightText: 2021 Johannes Loher
// SPDX-FileCopyrightText: 2021 Gesina Schwalbe
//
// SPDX-License-Identifier: MIT

import { getGame } from "../../utils/utils";

/**
 * The Item class for DS4
 */
export class DS4Item extends Item {
  /**
   * An object that tracks the changes to the data model which were applied by active effects
   * @type {Record<string, unknown>}
   */
  overrides = {};

  /** @override */
  prepareDerivedData() {
    this.system.rollable = false;
  }

  /**
   * Is this item a non-equipped equipable?
   * @returns {boolean} Whether the item is a non-equpped equibale or not
   */
  isNonEquippedEuipable() {
    return "equipped" in this.system && !this.system.equipped;
  }

  /**
   * The number of times that active effect changes originating from this item should be applied.
   * @returns {number | undefined} The number of times the effect should be applied
   */
  get activeEffectFactor() {
    return 1;
  }

  /**
   * The list of item types that are rollable.
   * @returns {import("../item/item-data-source").ItemType[]} The rollable item types
   */
  static get rollableItemTypes() {
    return ["weapon", "spell"];
  }

  /**
   * Roll a check for an action with this item.
   * @param {import("../common/roll-options").RollOptions} [options={}]    Additional options to customize the roll
   * @returns {Promise<void>} A promise that resolves once the roll has been performed
   * @abstract
   */
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  async roll(options = {}) {
    throw new Error(getGame().i18n.format("DS4.ErrorRollingForItemTypeNotPossible", { type: this.type }));
  }
}
