2021-02-11 02:48:27 +01:00
|
|
|
import { ChatUtility } from "../chat-utility.js";
|
2021-02-12 15:01:10 +01:00
|
|
|
import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js";
|
2021-02-11 02:48:27 +01:00
|
|
|
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' }
|
2021-02-12 01:16:02 +01:00
|
|
|
tooltip(linkData) { return `La ${this.tmrLabel(linkData)} a un présent` }
|
2021-02-12 12:50:17 +01:00
|
|
|
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/gift.svg' }
|
2021-02-11 02:48:27 +01:00
|
|
|
|
|
|
|
_createSprite(pixiTMR) {
|
|
|
|
return pixiTMR.sprite(this.code(),
|
|
|
|
{
|
2021-02-12 15:01:10 +01:00
|
|
|
zIndex: tmrTokenZIndex.tetes,
|
|
|
|
color: 0xFEFEFE,
|
|
|
|
alpha: 0.8,
|
|
|
|
taille: tmrConstants.third,
|
|
|
|
decallage: tmrConstants.topRight
|
2021-02-11 02:48:27 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async _ajouterPresents(actor) {
|
|
|
|
let existants = actor.data.items.filter(it => this.isCase(it)).map(it => it.data.coord);
|
2021-02-12 01:16:02 +01:00
|
|
|
if (existants.length > 0) {
|
2021-02-11 02:48:27 +01:00
|
|
|
ChatMessage.create({
|
2021-02-12 01:16:02 +01:00
|
|
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
2021-02-11 02:48:27 +01:00
|
|
|
content: "Vous avez encore des présents dans des cités, vous devrez tirer une autre tête pour remplacer celle ci!"
|
|
|
|
})
|
|
|
|
}
|
2021-02-12 01:16:02 +01:00
|
|
|
else {
|
2021-02-11 02:48:27 +01:00
|
|
|
let cites = TMRUtility.filterTMR(it => it.type == 'cite');
|
|
|
|
for (let tmr of cites) {
|
|
|
|
await this.createCaseTmr(actor, 'Présent: ' + tmr.label, tmr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-12 12:50:17 +01:00
|
|
|
|
|
|
|
async choisirUnPresent(casetmr, onChoixPresent) {
|
2021-02-12 01:44:27 +01:00
|
|
|
let d = new Dialog({
|
|
|
|
title: "Présent des cités",
|
2021-02-12 12:50:17 +01:00
|
|
|
content: `La ${this.tmrLabel(casetmr)} vous offre un présent, faite votre choix`,
|
2021-02-12 01:44:27 +01:00
|
|
|
buttons: {
|
2021-02-12 12:50:17 +01:00
|
|
|
messager: { icon: '<i class="fas fa-check"></i>', label: "Un Messager des rêves", callback: () => onChoixPresent('messager2d6') },
|
|
|
|
passeur: { icon: '<i class="fas fa-check"></i>', label: "Un Passeur des rêves", callback: () => onChoixPresent('passeur2d6') },
|
|
|
|
fleur: { icon: '<i class="fas fa-check"></i>', label: "Une Fleur des rêves", callback: () => onChoixPresent('fleur2d6') },
|
|
|
|
},
|
|
|
|
default: "fleur"
|
2021-02-12 01:44:27 +01:00
|
|
|
});
|
|
|
|
d.render(true);
|
|
|
|
}
|
|
|
|
|
2021-02-12 12:50:17 +01:00
|
|
|
async ouvrirLePresent(actor, casetmr) {
|
|
|
|
await actor.deleteOwnedItem(casetmr._id);
|
|
|
|
}
|
2021-02-11 02:48:27 +01:00
|
|
|
}
|