import { Grammar } from "../grammar.js";
import { TMRUtility } from "../tmr-utility.js";
import { tmrTokenZIndex } from "../tmr-constants.js";
import { Draconique } from "./draconique.js";

export class TrouNoir extends Draconique {

  type() { return 'souffle' }
  match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('trou noir'); }
  manualMessage() { return false }

  async onActorCreateOwned(actor, souffle) {
    const existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
    const selectedTMR = await TMRUtility.getTMRAleatoire(tmr => !(TMRUtility.isCaseHumide(tmr) || existants.includes(tmr.coord)));
    await this.createCaseTmr(actor, 'Trou noir', selectedTMR, souffle.id);
  }

  code() { return 'trounoir' }
  tooltip(linkData) { return `Trou noir` }
  img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/trounoir.svg' }

  createSprite(pixiTMR) {
    return pixiTMR.sprite(this.code(),
      {
        zIndex: tmrTokenZIndex.trounoir,
        decallage: pixiTMR.sizes.decallage(0, 0),
        taille: () => pixiTMR.sizes.full,
      });
  }

}
