2020-05-22 22:37:02 +02:00
|
|
|
import { RdDUtility } from "./rdd-utility.js";
|
2020-12-06 18:41:54 +01:00
|
|
|
import { HtmlUtility } from "./html-utility.js";
|
2021-01-04 00:17:22 +01:00
|
|
|
import { RdDItemArme } from "./item-arme.js";
|
2021-01-08 22:23:50 +01:00
|
|
|
import { RdDItemCompetence } from "./item-competence.js";
|
2021-01-13 03:42:13 +01:00
|
|
|
import { RdDBonus } from "./rdd-bonus.js";
|
2021-02-05 01:38:40 +01:00
|
|
|
import { Misc } from "./misc.js";
|
2021-02-25 02:13:39 +01:00
|
|
|
import { RdDCombatManager } from "./rdd-combat.js";
|
2021-03-17 01:21:37 +01:00
|
|
|
import { RdDCarac } from "./rdd-carac.js";
|
2021-04-13 00:58:05 +02:00
|
|
|
import { DialogSplitItem } from "./dialog-split-item.js";
|
2022-11-06 21:39:03 +01:00
|
|
|
import { ReglesOptionelles } from "./settings/regles-optionelles.js";
|
2021-06-26 00:55:54 +02:00
|
|
|
import { DialogRepos } from "./dialog-repos.js";
|
2021-12-05 01:48:26 +01:00
|
|
|
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
2022-11-06 21:39:03 +01:00
|
|
|
import { STATUSES } from "./settings/status-effects.js";
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-09-20 21:45:46 +02:00
|
|
|
/* -------------------------------------------- */
|
2022-11-05 18:06:30 +01:00
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
|
|
* @extends {ActorSheet}
|
|
|
|
*/
|
2020-05-22 00:48:43 +02:00
|
|
|
export class RdDActorSheet extends ActorSheet {
|
2020-05-21 21:48:20 +02:00
|
|
|
|
|
|
|
/** @override */
|
2021-01-08 22:23:50 +01:00
|
|
|
static get defaultOptions() {
|
2020-12-01 22:18:15 +01:00
|
|
|
RdDUtility.initAfficheContenu();
|
2021-01-08 22:23:50 +01:00
|
|
|
return mergeObject(super.defaultOptions, {
|
|
|
|
classes: ["rdd", "sheet", "actor"],
|
|
|
|
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
|
2020-07-27 16:27:41 +02:00
|
|
|
width: 640,
|
2021-01-08 22:23:50 +01:00
|
|
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
|
2022-11-05 18:06:30 +01:00
|
|
|
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }],
|
2021-01-08 22:23:50 +01:00
|
|
|
showCompNiveauBase: false,
|
2021-11-23 02:11:24 +01:00
|
|
|
vueDetaillee: false
|
2020-05-21 21:48:20 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-03-17 01:21:37 +01:00
|
|
|
async getData() {
|
2022-08-26 22:21:25 +02:00
|
|
|
this.timerRecherche = undefined;
|
2022-10-05 19:29:16 +02:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
let formData = {
|
|
|
|
title: this.title,
|
2022-09-07 18:47:56 +02:00
|
|
|
id: this.actor.id,
|
|
|
|
type: this.actor.type,
|
|
|
|
img: this.actor.img,
|
|
|
|
name: this.actor.name,
|
2021-03-25 03:18:27 +01:00
|
|
|
editable: this.isEditable,
|
|
|
|
cssClass: this.isEditable ? "editable" : "locked",
|
2022-09-07 18:47:56 +02:00
|
|
|
system: foundry.utils.deepClone(this.actor.system),
|
|
|
|
effects: this.actor.effects.map(e => foundry.utils.deepClone(e)),
|
|
|
|
limited: this.actor.limited,
|
2021-03-25 03:18:27 +01:00
|
|
|
options: this.options,
|
2022-09-07 18:47:56 +02:00
|
|
|
owner: this.actor.isOwner,
|
2022-10-05 19:29:16 +02:00
|
|
|
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
|
|
|
|
biographie: await TextEditor.enrichHTML(this.object.system.biographie, {async: true}),
|
|
|
|
notes: await TextEditor.enrichHTML(this.object.system.notes, {async: true}),
|
2022-09-27 21:03:18 +02:00
|
|
|
notesmj: await TextEditor.enrichHTML(this.object.system.notesmj, {async: true}),
|
2022-10-05 19:29:16 +02:00
|
|
|
calc: {
|
|
|
|
encTotal: await this.actor.computeEncombrementTotalEtMalusArmure(),
|
|
|
|
prixTotalEquipement: this.actor.computePrixTotalEquipement(),
|
|
|
|
surprise: RdDBonus.find(this.actor.getSurprise(false)).descr,
|
|
|
|
resumeBlessures: this.actor.computeResumeBlessure(this.actor.system.blessures),
|
|
|
|
caracTotal: RdDCarac.computeTotal(this.actor.system.carac, this.actor.system.beaute),
|
|
|
|
surEncombrementMessage: this.actor.getMessageSurEncombrement(),
|
|
|
|
},
|
2022-06-12 08:17:59 +02:00
|
|
|
}
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.options.isGM = game.user.isGM;
|
|
|
|
|
2022-09-26 23:01:29 +02:00
|
|
|
RdDUtility.filterItemsPerTypeForSheet(formData, this.actor.itemTypes);
|
2022-10-05 19:29:16 +02:00
|
|
|
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
|
|
|
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
2021-03-17 01:21:37 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
if (formData.type == 'personnage') {
|
|
|
|
formData.byCateg = Misc.classify(formData.competences, it => it.system.categorie)
|
|
|
|
formData.calc.comptageArchetype = RdDItemCompetence.computeResumeArchetype(formData.competences);
|
|
|
|
formData.calc.competenceXPTotal= RdDItemCompetence.computeTotalXP(formData.competences);
|
|
|
|
formData.calc.fatigue= RdDUtility.calculFatigueHtml(formData.system.sante.fatigue.value, formData.system.sante.endurance.max);
|
|
|
|
|
|
|
|
formData.competences.forEach(item => {
|
|
|
|
item.system.isVisible = this.options.recherche
|
2022-08-26 22:21:25 +02:00
|
|
|
? RdDItemCompetence.nomContientTexte(item, this.options.recherche.text)
|
2022-01-01 14:01:41 +01:00
|
|
|
: (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
|
2022-10-05 19:29:16 +02:00
|
|
|
RdDItemCompetence.levelUp(item, formData.system.compteurs.experience.value);
|
|
|
|
});
|
2020-08-13 22:28:56 +02:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
Object.values(formData.system.carac).forEach(c => {
|
|
|
|
RdDCarac.levelUp(c);
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
|
|
|
formData.combat = duplicate(formData.armes ?? []);
|
|
|
|
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences);
|
|
|
|
RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.system.carac);
|
|
|
|
formData.esquives = this.actor.getCompetences("Esquive");
|
|
|
|
formData.combat = RdDCombatManager.listActionsArmes(formData.combat, formData.competences, formData.system.carac);
|
2021-03-15 00:05:56 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
this.armesList = formData.combat;
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
// Common data
|
|
|
|
formData.ajustementsConditions = CONFIG.RDD.ajustementsConditions;
|
|
|
|
formData.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
2021-03-18 23:55:26 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.hautreve = {
|
|
|
|
isDemiReve: this.actor.getEffect(STATUSES.StatusDemiReve),
|
|
|
|
cacheTMR: this.actor.isTMRCache()
|
|
|
|
}
|
2021-05-07 01:47:51 +02:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.subacteurs = {
|
|
|
|
vehicules: this.actor.listeVehicules(),
|
|
|
|
montures: this.actor.listeMontures(),
|
|
|
|
suivants: this.actor.listeSuivants()
|
|
|
|
}
|
|
|
|
if (this.actor.getBestDraconic().system.niveau > -11 && !this.actor.isHautRevant()) {
|
|
|
|
ui.notifications.error(`${this.actor.name} a des compétences draconiques, mais pas le don de Haut-Rêve!
|
|
|
|
<br>Ajoutez-lui la tête "Don de Haut-Rêve" pour lui permettre d'utiliser ses compétences et d'accéder aux terres médianes du rêve`);
|
|
|
|
}
|
2021-04-04 00:16:49 +02:00
|
|
|
}
|
2021-03-16 22:56:57 +01:00
|
|
|
return formData;
|
2020-05-22 19:28:01 +02:00
|
|
|
}
|
2020-12-27 22:21:08 +01:00
|
|
|
|
2021-03-17 01:21:37 +01:00
|
|
|
isCompetenceAffichable(competence) {
|
|
|
|
return !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(competence);
|
|
|
|
}
|
|
|
|
|
2020-11-11 11:43:13 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-05-07 01:47:51 +02:00
|
|
|
async _onDropActor(event, dragData) {
|
2022-09-07 00:09:17 +02:00
|
|
|
const dropActor = fromUuidSync(dragData.uuid);
|
|
|
|
this.actor.addSubActeur(dropActor);
|
|
|
|
super._onDropActor(event, dragData);
|
2021-05-07 01:47:51 +02:00
|
|
|
}
|
2022-01-01 14:01:41 +01:00
|
|
|
|
2021-05-07 01:47:51 +02:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
async _onDropItem(event, dragData) {
|
2022-06-12 09:46:58 +02:00
|
|
|
const destItemId = $(event.target)?.closest('.item').attr('data-item-id')
|
|
|
|
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor.id, dragData, this.objetVersConteneur)
|
|
|
|
const callSuper = await this.actor.processDropItem(dropParams)
|
2021-05-07 01:47:51 +02:00
|
|
|
if (callSuper) {
|
|
|
|
await super._onDropItem(event, dragData)
|
2021-01-09 09:54:08 +01:00
|
|
|
}
|
2020-11-11 11:43:13 +01:00
|
|
|
}
|
2020-11-12 14:43:08 +01:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
async createItem(name, type) {
|
|
|
|
await this.actor.createEmbeddedDocuments('Item', [{ name: name, type: type }], { renderSheet: true });
|
|
|
|
}
|
|
|
|
|
2020-12-15 08:37:52 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-08 22:23:50 +01:00
|
|
|
async createEmptyTache() {
|
2021-03-25 03:18:27 +01:00
|
|
|
await this.createItem('Nouvelle tache', 'tache');
|
2020-12-15 08:37:52 +01:00
|
|
|
}
|
|
|
|
|
2021-06-02 16:04:35 +02:00
|
|
|
/* -------------------------------------------- */ /** @override */
|
2021-01-08 22:23:50 +01:00
|
|
|
activateListeners(html) {
|
2020-05-21 21:48:20 +02:00
|
|
|
super.activateListeners(html);
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2021-05-08 20:08:56 +02:00
|
|
|
HtmlUtility._showControlWhen($(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
|
2020-12-01 01:17:18 +01:00
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.item-split').click(async event => {
|
2022-06-12 08:17:59 +02:00
|
|
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
|
|
RdDSheetUtility.splitItem(item, this.actor);
|
2021-04-13 00:58:05 +02:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.item-edit').click(async event => {
|
2022-04-30 23:42:55 +02:00
|
|
|
const item = RdDSheetUtility.getItem(event, this.actor)
|
|
|
|
item.sheet.render(true)
|
2022-06-12 08:17:59 +02:00
|
|
|
})
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.display-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
2021-05-10 18:39:35 +02:00
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.item-delete').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
const li = RdDSheetUtility.getEventElement(event);
|
2022-09-17 01:53:13 +02:00
|
|
|
const item = this.actor.getObjet(li.data("item-id"));
|
|
|
|
RdDUtility.confirmerSuppressionItem(this, item, li);
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.item-vendre').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
2021-05-07 17:27:02 +02:00
|
|
|
item?.proposerVente();
|
|
|
|
});
|
2021-12-10 01:21:01 +01:00
|
|
|
html.find('.item-montrer').click(async event => {
|
|
|
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
|
|
item?.postItem();
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.item-action').click(async event => {
|
2022-06-12 08:17:59 +02:00
|
|
|
const item = RdDSheetUtility.getItem(event, this.actor)
|
2021-04-12 00:16:23 +02:00
|
|
|
this.actor.actionItem(item);
|
2021-04-06 23:44:57 +02:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.subacteur-delete').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
const li = RdDSheetUtility.getEventElement(event);
|
2022-09-17 01:53:13 +02:00
|
|
|
const actorId = li.data("actor-id");
|
|
|
|
if (actorId) {
|
|
|
|
const subActor = game.actors.get(actorId);
|
|
|
|
RdDUtility.confirmerSuppressionSubacteur(this, subActor, li);
|
|
|
|
}
|
2021-01-11 16:29:41 +01:00
|
|
|
});
|
2022-09-28 01:24:20 +02:00
|
|
|
html.find('.experiencelog-delete').click(async event => {
|
|
|
|
const li = $(event.currentTarget)?.parents(".experiencelog");
|
|
|
|
const key = Number(li.data("key") ?? -1);
|
|
|
|
await this.actor.deleteExperienceLog(key, 1);
|
|
|
|
});
|
|
|
|
html.find('.experiencelog-delete-previous').click(async event => {
|
|
|
|
const li = $(event.currentTarget)?.parents(".experiencelog");
|
|
|
|
const key = Number(li.data("key") ?? -1);
|
|
|
|
await this.actor.deleteExperienceLog(0, key + 1);
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.encaisser-direct').click(async event => {
|
2020-12-27 19:55:51 +01:00
|
|
|
this.actor.encaisser();
|
2022-06-12 08:17:59 +02:00
|
|
|
})
|
|
|
|
html.find('.sheet-possession-attack').click(async event => {
|
|
|
|
const poss = RdDSheetUtility.getItem(event, this.actor)
|
|
|
|
this.actor.conjurerPossession(poss)
|
|
|
|
})
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.remise-a-neuf').click(async event => {
|
2020-12-01 01:17:18 +01:00
|
|
|
if (game.user.isGM) {
|
|
|
|
this.actor.remiseANeuf();
|
|
|
|
}
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.creer-tache').click(async event => {
|
2020-12-15 08:37:52 +01:00
|
|
|
this.createEmptyTache();
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.creer-un-objet').click(async event => {
|
2022-01-01 14:01:41 +01:00
|
|
|
RdDUtility.selectObjetType(this);
|
2020-12-15 22:44:49 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.creer-une-oeuvre').click(async event => {
|
2021-06-07 23:18:33 +02:00
|
|
|
RdDUtility.selectTypeOeuvre(this);
|
2021-03-31 00:11:35 +02:00
|
|
|
});
|
2022-10-04 01:53:18 +02:00
|
|
|
html.find('.nettoyer-conteneurs').click(async event => {
|
2021-01-08 11:56:10 +01:00
|
|
|
this.actor.nettoyerConteneurs();
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-07-27 16:27:41 +02:00
|
|
|
// Blessure control
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.blessure-control').click(async event => {
|
|
|
|
const tr = $(event.currentTarget).parents(".item");
|
|
|
|
let btype = tr.data("blessure-type");
|
|
|
|
let index = tr.data('blessure-index');
|
|
|
|
let active = $(event.currentTarget).data('blessure-active');
|
2020-07-27 16:27:41 +02:00
|
|
|
//console.log(btype, index, active);
|
2021-06-01 20:02:26 +02:00
|
|
|
await this.actor.manageBlessureFromSheet(btype, index, active);
|
2020-07-27 16:27:41 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Blessure data
|
2022-09-26 02:23:07 +02:00
|
|
|
html.find('.blessure-soins').change(async event => {
|
2021-06-01 20:02:26 +02:00
|
|
|
const tr = $(event.currentTarget).parents(".item");
|
|
|
|
let btype = tr.data('blessure-type');
|
|
|
|
let index = tr.data('blessure-index');
|
|
|
|
let psoins = tr.find('.blessure-premiers_soins').val();
|
|
|
|
let pcomplets = tr.find('.blessure-soins_complets').val();
|
|
|
|
let jours = tr.find('.blessure-jours').val();
|
|
|
|
let loc = tr.find('.blessure-localisation').val();
|
2021-10-29 22:37:27 +02:00
|
|
|
let psdone = tr.find('.blessure-psdone:checked').val();
|
|
|
|
let scdone = tr.find('.blessure-scdone:checked').val();
|
|
|
|
console.log(btype, index, psoins, pcomplets, jours, loc, psdone, scdone);
|
|
|
|
await this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc, psdone, scdone);
|
2020-07-20 12:02:07 +02:00
|
|
|
});
|
|
|
|
|
2020-06-23 23:34:12 +02:00
|
|
|
// Equip Inventory Item
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.item-equip').click(async event => {
|
2022-06-12 08:17:59 +02:00
|
|
|
this.actor.equiperObjet(RdDSheetUtility.getItemId(event));
|
2020-06-23 23:34:12 +02:00
|
|
|
});
|
|
|
|
|
2020-06-12 22:46:04 +02:00
|
|
|
// Roll Carac
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.carac-label a').click(async event => {
|
2020-06-12 22:46:04 +02:00
|
|
|
let caracName = event.currentTarget.attributes.name.value;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.rollCarac(caracName.toLowerCase());
|
2020-06-12 22:46:04 +02:00
|
|
|
});
|
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.chance-actuelle').click(async event => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.rollCarac('chance-actuelle');
|
2020-12-06 18:41:54 +01:00
|
|
|
});
|
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.chance-appel').click(async event => {
|
2020-12-06 23:31:23 +01:00
|
|
|
this.actor.rollAppelChance();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('#jet-astrologie').click(async event => {
|
2020-12-11 08:29:24 +01:00
|
|
|
this.actor.astrologieNombresAstraux();
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-05-22 22:37:02 +02:00
|
|
|
// Roll Skill
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('a.competence-label').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollCompetence(RdDSheetUtility.getItemId(event));
|
2020-05-22 22:37:02 +02:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.tache-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollTache(RdDSheetUtility.getItemId(event));
|
2020-12-15 08:37:52 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.meditation-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollMeditation(RdDSheetUtility.getItemId(event));
|
2021-01-04 22:03:00 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.chant-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollChant(RdDSheetUtility.getItemId(event));
|
2021-01-27 23:35:45 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.danse-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollDanse(RdDSheetUtility.getItemId(event));
|
2021-01-27 23:35:45 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.musique-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollMusique(RdDSheetUtility.getItemId(event));
|
2021-01-27 23:35:45 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.oeuvre-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollOeuvre(RdDSheetUtility.getItemId(event));
|
2021-02-06 01:34:01 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.jeu-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollJeu(RdDSheetUtility.getItemId(event));
|
2021-01-27 23:35:45 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.recettecuisine-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.rollRecetteCuisine(RdDSheetUtility.getItemId(event));
|
2021-01-27 23:35:45 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.subacteur-label a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
let actorId = RdDSheetUtility.getEventItemData(event, 'actor-id');
|
2021-03-15 00:05:56 +01:00
|
|
|
let actor = game.actors.get(actorId);
|
|
|
|
if (actor) {
|
2021-01-11 16:29:41 +01:00
|
|
|
actor.sheet.render(true);
|
|
|
|
}
|
|
|
|
});
|
2021-05-24 22:12:37 +02:00
|
|
|
|
2021-04-28 00:48:39 +02:00
|
|
|
// Boutons spéciaux MJs
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.forcer-tmr-aleatoire').click(async event => {
|
2022-06-25 17:49:19 +02:00
|
|
|
this.actor.reinsertionAleatoire("Action MJ");
|
2021-04-28 00:48:39 +02:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.afficher-tmr').click(async event => {
|
2022-09-30 01:55:04 +02:00
|
|
|
this.actor.changeTMRVisible();
|
2021-04-28 00:48:39 +02:00
|
|
|
});
|
2021-05-24 22:12:37 +02:00
|
|
|
|
2020-11-15 12:26:19 +01:00
|
|
|
// Points de reve actuel
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.ptreve-actuel a').click(async event => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.rollCarac('reve-actuel');
|
2020-12-06 21:56:59 +01:00
|
|
|
});
|
|
|
|
|
2020-11-15 12:26:19 +01:00
|
|
|
// Roll Weapon1
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.arme-label a').click(async event => {
|
2022-06-12 08:17:59 +02:00
|
|
|
let arme = this._getEventArmeCombat(event);
|
|
|
|
this.actor.rollArme(duplicate(arme));
|
2020-06-07 23:16:29 +02:00
|
|
|
});
|
2020-12-05 21:24:31 +01:00
|
|
|
// Initiative pour l'arme
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.arme-initiative a').click(async event => {
|
2022-09-07 18:47:56 +02:00
|
|
|
let combatant = game.combat.combatants.find(c => c.actor.id == this.actor.id);
|
2021-01-08 22:23:50 +01:00
|
|
|
if (combatant) {
|
2022-07-03 15:32:20 +02:00
|
|
|
let action = this._getEventArmeCombat(event);
|
|
|
|
RdDCombatManager.rollInitiativeAction(combatant._id, action);
|
2020-12-05 21:24:31 +01:00
|
|
|
} else {
|
|
|
|
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
|
|
|
|
}
|
|
|
|
});
|
2022-04-23 01:02:03 +02:00
|
|
|
// Display TMR, visualisation
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.visu-tmr').click(async event => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.displayTMR("visu");
|
2020-11-14 20:46:39 +01:00
|
|
|
});
|
|
|
|
|
2020-07-25 10:29:28 +02:00
|
|
|
// Display TMR, normal
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.monte-tmr').click(async event => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.displayTMR("normal");
|
2020-07-25 10:29:28 +02:00
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-07-25 10:29:28 +02:00
|
|
|
// Display TMR, fast
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.monte-tmr-rapide').click(async event => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.displayTMR("rapide");
|
2020-07-24 10:51:11 +02:00
|
|
|
});
|
|
|
|
|
2021-06-26 00:55:54 +02:00
|
|
|
html.find('.repos').click(async event => {
|
|
|
|
await DialogRepos.create(this.actor);
|
2020-11-24 18:54:13 +01:00
|
|
|
});
|
2021-06-29 00:56:25 +02:00
|
|
|
html.find('.delete-active-effect').click(async event => {
|
2022-09-17 22:36:43 +02:00
|
|
|
if (game.user.isGM) {
|
|
|
|
let effect = $(event.currentTarget).parents(".active-effect").data('effect');
|
|
|
|
this.actor.removeEffect(effect);
|
|
|
|
}
|
2021-06-29 00:56:25 +02:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.enlever-tous-effets').click(async event => {
|
2022-09-17 22:36:43 +02:00
|
|
|
if (game.user.isGM) {
|
2022-09-19 20:15:01 +02:00
|
|
|
await this.actor.removeEffects();
|
2022-09-17 22:36:43 +02:00
|
|
|
}
|
2021-01-13 03:42:13 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.conteneur-name a').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
|
2020-12-01 22:18:15 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.carac-xp-augmenter').click(async event => {
|
2021-05-28 00:55:22 +02:00
|
|
|
let caracName = event.currentTarget.name.replace("augmenter.", "");
|
|
|
|
this.actor.updateCaracXPAuto(caracName);
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.competence-xp-augmenter').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event));
|
2021-05-28 00:55:22 +02:00
|
|
|
});
|
2021-11-23 02:04:00 +01:00
|
|
|
html.find('.competence-stress-augmenter').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event));
|
2021-11-23 02:04:00 +01:00
|
|
|
});
|
|
|
|
|
2022-09-27 22:38:49 +02:00
|
|
|
if (this.options.vueDetaillee) {
|
2020-11-20 12:06:54 +01:00
|
|
|
// On carac change
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.carac-value').change(async event => {
|
2022-09-07 09:01:23 +02:00
|
|
|
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "");
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCarac(caracName, parseInt(event.target.value));
|
|
|
|
});
|
2022-09-07 00:09:17 +02:00
|
|
|
html.find('input.carac-xp').change(async event => {
|
2022-09-07 09:01:23 +02:00
|
|
|
let caracName = event.currentTarget.name.replace(".xp", "").replace("system.carac.", "");
|
2022-06-12 08:17:59 +02:00
|
|
|
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
|
2021-01-08 22:23:50 +01:00
|
|
|
});
|
2020-11-20 12:06:54 +01:00
|
|
|
// On competence change
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.competence-value').change(async event => {
|
2020-11-20 12:06:54 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
|
|
//console.log("Competence changed :", compName);
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCompetence(compName, parseInt(event.target.value));
|
|
|
|
});
|
2020-11-20 12:06:54 +01:00
|
|
|
// On competence xp change
|
2022-09-07 00:09:17 +02:00
|
|
|
html.find('input.competence-xp').change(async event => {
|
2020-11-20 12:06:54 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCompetenceXP(compName, parseInt(event.target.value));
|
|
|
|
});
|
2021-02-03 23:27:55 +01:00
|
|
|
// On competence xp change
|
2022-09-07 00:09:17 +02:00
|
|
|
html.find('input.competence-xp-sort').change(async event => {
|
2021-02-03 23:27:55 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
|
|
this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value));
|
|
|
|
});
|
2021-01-03 19:19:02 +01:00
|
|
|
// On competence archetype change
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.competence-archetype').change(async event => {
|
2021-01-03 19:19:02 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value));
|
|
|
|
});
|
2020-11-20 12:06:54 +01:00
|
|
|
}
|
2022-01-01 14:01:41 +01:00
|
|
|
|
2021-11-23 02:11:24 +01:00
|
|
|
html.find('.show-hide-competences').click(async event => {
|
2021-06-01 20:02:26 +02:00
|
|
|
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
|
|
|
|
this.render(true);
|
|
|
|
});
|
2022-08-26 22:21:25 +02:00
|
|
|
|
|
|
|
html.find('.recherche')
|
|
|
|
.each((index, field) => {
|
|
|
|
if (this.options.recherche) {
|
|
|
|
field.focus();
|
|
|
|
field.setSelectionRange(this.options.recherche.start, this.options.recherche.end);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.keyup(async event => {
|
2022-08-27 22:45:26 +02:00
|
|
|
const nouvelleRecherche = this._optionRecherche(event.currentTarget);
|
|
|
|
if (this.options.recherche?.text != nouvelleRecherche?.text){
|
|
|
|
this.options.recherche = nouvelleRecherche;
|
|
|
|
if (this.timerRecherche) {
|
|
|
|
clearTimeout(this.timerRecherche);
|
|
|
|
}
|
|
|
|
this.timerRecherche = setTimeout(() => {
|
|
|
|
this.timerRecherche = undefined;
|
|
|
|
this.render(true);
|
|
|
|
}, 500);
|
2022-08-26 22:21:25 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.change(async event =>
|
|
|
|
this.options.recherche = this._optionRecherche(event.currentTarget)
|
|
|
|
);
|
2021-11-23 02:11:24 +01:00
|
|
|
html.find('.vue-detaillee').click(async event => {
|
|
|
|
this.options.vueDetaillee = !this.options.vueDetaillee;
|
2021-05-13 00:38:06 +02:00
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-07-14 22:19:29 +02:00
|
|
|
// On pts de reve change
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.pointsreve-value').change(async event => {
|
2020-07-14 22:19:29 +02:00
|
|
|
let reveValue = event.currentTarget.value;
|
2022-09-07 18:47:56 +02:00
|
|
|
this.actor.update({ "system.reve.reve.value": reveValue });
|
2021-01-08 22:23:50 +01:00
|
|
|
});
|
|
|
|
|
2020-11-16 03:52:34 +01:00
|
|
|
// On seuil de reve change
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.seuil-reve-value').change(async event => {
|
2020-11-16 03:52:34 +01:00
|
|
|
console.log("seuil-reve-value", event.currentTarget)
|
|
|
|
this.actor.setPointsDeSeuil(event.currentTarget.value);
|
2021-01-08 22:23:50 +01:00
|
|
|
});
|
2020-07-14 22:19:29 +02:00
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('#attribut-protection-edit').change(async event => {
|
2021-03-22 20:10:37 +01:00
|
|
|
this.actor.updateAttributeValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
|
2021-01-08 22:23:50 +01:00
|
|
|
});
|
2020-12-18 01:10:03 +01:00
|
|
|
|
2020-08-29 22:52:41 +02:00
|
|
|
// On stress change
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.compteur-edit').change(async event => {
|
2020-08-29 22:52:41 +02:00
|
|
|
let fieldName = event.currentTarget.attributes.name.value;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCompteurValue(fieldName, parseInt(event.target.value));
|
|
|
|
});
|
2020-12-29 01:34:15 +01:00
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('#ethylisme').change(async event => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.setEthylisme(parseInt(event.target.value));
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.stress-test').click(async event => {
|
2021-01-29 12:08:02 +01:00
|
|
|
this.actor.transformerStress();
|
2020-08-29 22:52:41 +02:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.moral-malheureux').click(async event => {
|
2020-12-16 02:54:28 +01:00
|
|
|
this.actor.jetDeMoral('malheureuse');
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.moral-neutre').click(async event => {
|
2020-12-16 02:54:28 +01:00
|
|
|
this.actor.jetDeMoral('neutre');
|
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.moral-heureux').click(async event => {
|
2020-12-16 02:54:28 +01:00
|
|
|
this.actor.jetDeMoral('heureuse');
|
|
|
|
});
|
2022-10-05 19:29:16 +02:00
|
|
|
html.find('.ethylisme-test').click(async event => {
|
2021-04-06 23:39:27 +02:00
|
|
|
this.actor.jetEthylisme();
|
2020-12-06 20:11:30 +01:00
|
|
|
});
|
2020-12-06 21:39:55 +01:00
|
|
|
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.jet-vie').click(async event => {
|
2020-12-06 21:39:55 +01:00
|
|
|
this.actor.jetVie();
|
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.jet-endurance').click(async event => {
|
2021-01-29 16:58:45 +01:00
|
|
|
this.actor.jetEndurance();
|
|
|
|
});
|
2020-12-31 00:55:02 +01:00
|
|
|
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.monnaie-plus').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.monnaieIncDec(RdDSheetUtility.getItemId(event), 1);
|
2020-12-31 00:55:02 +01:00
|
|
|
});
|
2021-06-01 20:02:26 +02:00
|
|
|
html.find('.monnaie-moins').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
this.actor.monnaieIncDec(RdDSheetUtility.getItemId(event), -1);
|
2020-12-31 00:55:02 +01:00
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.vie-plus').click(async event => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("vie", 1);
|
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.vie-moins').click(async event => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("vie", -1);
|
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.endurance-plus').click(async event => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("endurance", 1);
|
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.endurance-moins').click(async event => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("endurance", -1);
|
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.ptreve-actuel-plus').click(async event => {
|
2020-11-27 10:21:20 +01:00
|
|
|
this.actor.reveActuelIncDec(1);
|
2020-11-18 18:37:15 +01:00
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.ptreve-actuel-moins').click(async event => {
|
2020-11-27 10:21:20 +01:00
|
|
|
this.actor.reveActuelIncDec(-1);
|
2020-11-17 19:29:18 +01:00
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.fatigue-plus').click(async event => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("fatigue", 1);
|
|
|
|
});
|
2021-11-26 01:00:28 +01:00
|
|
|
html.find('.fatigue-moins').click(async event => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("fatigue", -1);
|
|
|
|
});
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2022-08-26 22:21:25 +02:00
|
|
|
_optionRecherche(target) {
|
|
|
|
if (!target.value?.length){
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
text: target.value,
|
|
|
|
start: target.selectionStart,
|
|
|
|
end: target.selectionEnd,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-11-23 02:04:00 +01:00
|
|
|
_getEventArmeCombat(event) {
|
2022-06-12 08:17:59 +02:00
|
|
|
const li = $(event.currentTarget)?.parents(".item");
|
|
|
|
let armeName = li.data("arme-name");
|
|
|
|
let compName = li.data('competence-name');
|
2022-06-12 09:46:58 +02:00
|
|
|
const arme = this.armesList.find(a => a.name == armeName && a.system.competence == compName);
|
2021-11-20 01:19:29 +01:00
|
|
|
if (!arme) {
|
2022-06-12 09:46:58 +02:00
|
|
|
return { name: armeName, system: { competence: compName } };
|
2021-11-20 01:19:29 +01:00
|
|
|
}
|
2022-06-12 08:17:59 +02:00
|
|
|
return arme;
|
2021-11-20 01:19:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
2021-01-08 22:23:50 +01:00
|
|
|
setPosition(options = {}) {
|
2020-05-21 21:48:20 +02:00
|
|
|
const position = super.setPosition(options);
|
2021-05-09 18:16:01 +02:00
|
|
|
const sheetHeader = this.element.find(".sheet-header");
|
|
|
|
const sheetTabs = this.element.find(".sheet-tabs");
|
2020-05-21 21:48:20 +02:00
|
|
|
const sheetBody = this.element.find(".sheet-body");
|
2022-10-05 19:29:16 +02:00
|
|
|
let bodyHeight = position.height - sheetHeader[0].clientHeight;
|
|
|
|
if (sheetTabs.length>0) {
|
|
|
|
bodyHeight -= sheetTabs[0].clientHeight;
|
|
|
|
}
|
2020-05-21 21:48:20 +02:00
|
|
|
sheetBody.css("height", bodyHeight);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
_updateObject(event, formData) {
|
|
|
|
// Update the Actor
|
2022-09-07 18:47:56 +02:00
|
|
|
return this.actor.update(formData);
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|
2021-04-13 00:58:05 +02:00
|
|
|
|
|
|
|
async splitItem(item) {
|
|
|
|
const dialog = await DialogSplitItem.create(item, (item, split) => this._onSplitItem(item, split));
|
|
|
|
dialog.render(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
async _onSplitItem(item, split) {
|
2022-09-07 00:09:17 +02:00
|
|
|
if (split >= 1 && split < item.system.quantite) {
|
2022-06-12 08:17:59 +02:00
|
|
|
await item.diminuerQuantite(split);
|
2022-09-07 18:47:56 +02:00
|
|
|
const splitItem = duplicate(item);
|
|
|
|
splitItem.system.quantite = split;
|
|
|
|
await this.actor.createEmbeddedDocuments('Item', [splitItem])
|
2021-04-13 00:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|