2023-11-24 02:17:20 +01:00
|
|
|
import { Grammar } from "../grammar.js";
|
2024-12-09 22:04:47 +01:00
|
|
|
import { ITEM_TYPES } from "../item.js";
|
2023-11-04 03:42:39 +01:00
|
|
|
import { RdDSheetUtility } from "../rdd-sheet-utility.js";
|
|
|
|
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
|
|
* @extends {ActorSheet}
|
|
|
|
*/
|
|
|
|
export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
|
|
|
|
|
2023-11-06 23:02:22 +01:00
|
|
|
/** @override */
|
|
|
|
static get defaultOptions() {
|
2024-05-01 09:13:21 +02:00
|
|
|
return foundry.utils.mergeObject(RdDBaseActorSheet.defaultOptions, {
|
2023-11-06 23:02:22 +01:00
|
|
|
width: 550
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2023-11-04 03:42:39 +01:00
|
|
|
/** @override */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-encaissement').click(async event => this.actor.encaisser())
|
|
|
|
this.html.find('.roll-carac').click(async event => {
|
|
|
|
this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))});
|
2024-10-05 12:41:28 +02:00
|
|
|
this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event)));
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1));
|
|
|
|
this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1));
|
2023-11-04 03:42:39 +01:00
|
|
|
|
2023-11-24 02:17:20 +01:00
|
|
|
if (game.user.isGM) {
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-remise-a-neuf').click(async event => this.actor.remiseANeuf())
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.delete-active-effect').click(async event => this.actor.removeEffect(this.html.find(event.currentTarget).parents(".active-effect").data('effect')));
|
|
|
|
this.html.find('.enlever-tous-effets').click(async event => await this.actor.removeEffects());
|
|
|
|
}
|
2024-12-09 22:04:47 +01:00
|
|
|
this.html.find('.competence-add').click(async event =>
|
|
|
|
await this.actor.createEmbeddedDocuments("Item", [{
|
|
|
|
type: ITEM_TYPES.competencecreature,
|
|
|
|
name: 'Nouvelle competence',
|
|
|
|
img: 'systems/foundryvtt-reve-de-dragon/icons/compcreature-serres.webp',
|
|
|
|
system: {
|
|
|
|
carac_value: this.actor.getForce(),
|
|
|
|
}
|
|
|
|
}], { renderSheet: true })
|
|
|
|
)
|
2023-11-04 03:42:39 +01:00
|
|
|
|
2024-12-14 00:38:39 +01:00
|
|
|
if (this.options.vueDetaillee) {
|
|
|
|
// On carac change
|
|
|
|
this.html.find('.carac-value').change(async event => {
|
|
|
|
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "");
|
|
|
|
this.actor.updateCarac(caracName, parseInt(event.target.value));
|
|
|
|
});
|
|
|
|
// On competence change
|
|
|
|
this.html.find('.competence-value').change(async event => {
|
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
|
|
//console.log("Competence changed :", compName);
|
|
|
|
this.actor.updateCompetence(compName, parseInt(event.target.value));
|
|
|
|
});
|
|
|
|
}
|
2023-11-04 03:42:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|