L'appréciation utilise: - un niveau de qualité (qui réutilise la qualité sur les items en ayant) - un bon moment (coeur/musique/...) - un niveau de jet de moral - une caractéristique (perception) - une compétence Les bon moments passés sont remis à zéro lors du passage de château dormant. Ajout des jets de moral très heureux. Ajout de jet d'appréciation sur les résultats des oeuvres et des jeux.
71 lines
2.0 KiB
JavaScript
71 lines
2.0 KiB
JavaScript
import { ENTITE_NONINCARNE } from "./constants.js";
|
|
import { DialogSelect } from "./dialog-select.js";
|
|
|
|
export class Targets {
|
|
static listTargets() {
|
|
return Array.from(game.user.targets);
|
|
}
|
|
|
|
static hasTargets() {
|
|
return Targets.listTargets().length > 0;
|
|
}
|
|
|
|
static extractTokenData(target) {
|
|
return {
|
|
id: target?.id,
|
|
name: target?.document.name,
|
|
img: target?.document.texture.src ?? target?.actor.img ?? 'icons/svg/mystery-man.svg'
|
|
}
|
|
}
|
|
|
|
static extractActorData(actor) {
|
|
return {
|
|
id: actor.id,
|
|
name: actor.prototypeToken?.name ?? actor.name,
|
|
img: actor.prototypeToken?.texture.src ?? actor.img ?? 'icons/svg/mystery-man.svg'
|
|
}
|
|
}
|
|
|
|
static buildActorTokenData(tokenId, actor) {
|
|
return { id: tokenId, name: actor.name, img: actor.img ?? 'icons/svg/mystery-man.svg' };
|
|
}
|
|
|
|
static isTargetEntite(target) {
|
|
return target?.actor.type == 'entite' && target?.actor.system.definition.typeentite == ENTITE_NONINCARNE;
|
|
}
|
|
|
|
static async selectOneTargetToken(onSelectTarget = target => { }) {
|
|
const targets = Targets.listTargets()
|
|
switch (targets.length) {
|
|
case 0:
|
|
return
|
|
case 1:
|
|
onSelectTarget(targets[0])
|
|
return
|
|
default:
|
|
{
|
|
const selectData = {
|
|
title: "Choisir une cible",
|
|
label: "Choisir une seule des cibles",
|
|
list: targets.map(it => Targets.extractTokenData(it))
|
|
};
|
|
DialogSelect.select(selectData, target => onSelectTarget(targets.find(it => it.id == target.id)))
|
|
}
|
|
}
|
|
}
|
|
|
|
static getTarget(options = { warn: true }) {
|
|
const targets = Targets.listTargets();
|
|
switch (targets.length) {
|
|
case 1:
|
|
return targets[0];
|
|
case 0:
|
|
if (options.warn) ui.notifications.warn("Vous devez choisir une cible à attaquer!");
|
|
break;
|
|
default:
|
|
if (options.warn) ui.notifications.warn("Vous devez choisir une cible (et <strong>une seule</strong>) à attaquer!");
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
} |