import { ChatUtility } from "../chat-utility.js"; import { tmrColors, tmrConstants, TMRUtility } from "../tmr-utility.js"; import { Draconique } from "./draconique.js"; export class PresentCites extends Draconique { constructor() { super(); } type() { return 'tete' } match(item) { return Draconique.isTeteDragon(item) && item.name.toLowerCase() == 'présent des cités'; } manualMessage() { return false } async onActorCreateOwned(actor, item) { await this._ajouterPresents(actor); } code() { return 'present-cites' } tooltip(linkData) { return `La ${this.tmrLabel(linkData)} a un présent` } img() { return 'systems/foundryvtt-reve-de-dragon/icons/svg/gift.svg' } _createSprite(pixiTMR) { return pixiTMR.sprite(this.code(), { color: tmrColors.tetes, alpha: 0.7, taille: tmrConstants.third, decallage: tmrConstants.topRight }); } async _ajouterPresents(actor) { let existants = actor.data.items.filter(it => this.isCase(it)).map(it => it.data.coord); if (existants.length > 0) { ChatMessage.create({ whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), content: "Vous avez encore des présents dans des cités, vous devrez tirer une autre tête pour remplacer celle ci!" }) } else { let cites = TMRUtility.filterTMR(it => it.type == 'cite'); for (let tmr of cites) { await this.createCaseTmr(actor, 'Présent: ' + tmr.label, tmr); } } } }