509b7f97dc
Utilisation de system dans les data de formulaire pour tous les Item/Actor (à la base, ou les sous-éléments) Corrections sur les sorts en réserve (ce ne sont pas des Item) Petites améliorations: * `actor.itemTypes[type]` revient à faire (sans besoin de filtrer) `actor.items.filter(it => it.type == type)` * dans les ItemSheet, this.object et this.document remplacés par this.item * dans les ActorSheet, this.object et this.document remplacés par this.actor Quelques corrections en plus: * parade ne marchait pas * problèmes sur le commerce
80 lines
2.8 KiB
JavaScript
80 lines
2.8 KiB
JavaScript
|
|
/**
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
* @extends {ActorSheet}
|
|
*/
|
|
|
|
import { HtmlUtility } from "./html-utility.js";
|
|
import { RdDUtility } from "./rdd-utility.js";
|
|
import { RdDActorSheet } from "./actor-sheet.js";
|
|
import { RdDCarac } from "./rdd-carac.js";
|
|
|
|
/* -------------------------------------------- */
|
|
export class RdDActorCreatureSheet extends RdDActorSheet {
|
|
|
|
/** @override */
|
|
static get defaultOptions() {
|
|
return mergeObject(super.defaultOptions, {
|
|
classes: ["rdd", "sheet", "actor"],
|
|
template: "systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html",
|
|
width: 640,
|
|
height: 720,
|
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
|
|
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }]
|
|
});
|
|
}
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
async getData() {
|
|
let formData = await super.getData()
|
|
//console.log("Creature : ", formData, formData.system)
|
|
formData.calc = {
|
|
caracTotal: RdDCarac.computeTotal(formData.system.carac),
|
|
resumeBlessures: this.actor.computeResumeBlessure(formData.system.blessures),
|
|
encTotal: await this.actor.computeEncombrementTotalEtMalusArmure(),
|
|
surEncombrementMessage: this.actor.getMessageSurEncombrement()
|
|
}
|
|
|
|
RdDUtility.filterItemsPerTypeForSheet(formData);
|
|
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
|
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
|
|
|
console.log("Creature : ", this.objetVersConteneur, formData);
|
|
|
|
return formData;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
/** @override */
|
|
activateListeners(html) {
|
|
super.activateListeners(html);
|
|
|
|
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
if (!this.options.editable) return;
|
|
|
|
// On competence change
|
|
html.find('.creature-carac').change(async event => {
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
|
|
});
|
|
html.find('.creature-niveau').change(async event => {
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
|
|
});
|
|
html.find('.creature-dommages').change(async event => {
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
|
|
});
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
/** @override */
|
|
_updateObject(event, formData) {
|
|
// Update the Actor
|
|
return this.object.update(formData);
|
|
}
|
|
}
|