import { tmrTokenZIndex } from "../tmr-constants.js";
import { TMRUtility } from "../tmr-utility.js";
import { Draconique } from "./draconique.js";
import { EffetsDraconiques } from "./effets-draconiques.js";

export class SortReserve extends Draconique {

  type() { return '' }
  match(item) { return false; }
  manualMessage() { return false }
  async onActorCreateOwned(actor, item) { }

  code() { return 'sortreserve' }
  tooltip(sort) { return `${sort.name}, r${sort.system.ptreve}` }
  img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/sort-reserve.svg' }

  createSprite(pixiTMR) {
    return pixiTMR.sprite(this.code(), {
      zIndex: tmrTokenZIndex.sort,
      decallage: pixiTMR.sizes.decallage(-0.6, 0),
      taille: () => pixiTMR.sizes.half,
    });
  }
  
  tokens(pixiTMR, linkData, coordTMR, type = undefined) {
    if (TMRUtility.getTMR(coordTMR()).type == 'fleuve') {
      const tooltip = this.tooltip(linkData)
      const fleuves = TMRUtility.getListTMR('fleuve')
      return fleuves.map(f => EffetsDraconiques.sortReserveHumide._createToken(pixiTMR, linkData, () => f.coord, type?? this.code(), tooltip))
    }
    return super.tokens(pixiTMR, linkData, coordTMR, type)
  }
}

export class SortReserveHumide extends SortReserve {
  code() { return 'sortreservehumide' }
  tooltip(sort) { return `${sort.name} en fleuve, r${sort.system.ptreve}` }
  img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/sort-reserve-humide.svg' }
}