2020-05-21 21:48:20 +02:00
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
|
|
* @extends {ActorSheet}
|
|
|
|
*/
|
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-06 23:36:35 +02:00
|
|
|
import { RdDItem } from "./item.js";
|
2021-04-13 00:58:05 +02:00
|
|
|
import { DialogSplitItem } from "./dialog-split-item.js";
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-09-20 21:45:46 +02:00
|
|
|
/* -------------------------------------------- */
|
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,
|
2020-11-29 18:21:34 +01:00
|
|
|
//height: 720,
|
2021-01-08 22:23:50 +01:00
|
|
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
|
|
|
|
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
2020-12-06 22:19:40 +01:00
|
|
|
editCaracComp: false,
|
2021-01-08 22:23:50 +01:00
|
|
|
showCompNiveauBase: false,
|
2021-01-03 19:19:02 +01:00
|
|
|
montrerArchetype: false
|
2020-05-21 21:48:20 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-03-17 01:21:37 +01:00
|
|
|
async getData() {
|
2021-03-25 03:18:27 +01:00
|
|
|
// 0.8.0
|
|
|
|
const objectData = Misc.data(this.object);
|
2021-03-17 01:21:37 +01:00
|
|
|
// -------------- version 0.7.9
|
|
|
|
// let formData = {
|
|
|
|
// cssClass: this.entity.owner ? "editable" : "locked",
|
|
|
|
// editable: this.isEditable,
|
|
|
|
// entity: duplicate(this.entity.data),
|
|
|
|
// limited: this.entity.limited,
|
|
|
|
// options: this.options,
|
|
|
|
// owner: this.entity.owner,
|
|
|
|
// title: this.title
|
|
|
|
// }
|
|
|
|
// // Entity data
|
|
|
|
// formData.actor = formData.entity;
|
|
|
|
// formData.data = formData.entity.data;
|
2021-04-13 00:58:05 +02:00
|
|
|
|
2021-03-17 01:21:37 +01:00
|
|
|
// // Owned items
|
|
|
|
// formData.items = formData.actor.items;
|
|
|
|
// formData.items.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
2021-04-13 00:58:05 +02:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
// -------------- version 0.8.0
|
2021-04-13 00:58:05 +02:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
// // Copy and sort Items
|
|
|
|
// items.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
|
|
|
// data.items = items;
|
2021-04-13 00:58:05 +02:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
// // Copy Active Effects
|
|
|
|
// data.effects = effects;
|
2021-04-13 00:58:05 +02:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
// // Return template data
|
|
|
|
let formData = {
|
|
|
|
title: this.title,
|
|
|
|
id: objectData.id,
|
|
|
|
type: objectData.type,
|
|
|
|
img: objectData.img,
|
|
|
|
name: objectData.name,
|
|
|
|
// actor: this.object,
|
|
|
|
editable: this.isEditable,
|
|
|
|
cssClass: this.isEditable ? "editable" : "locked",
|
|
|
|
data: foundry.utils.deepClone(Misc.templateData(this.object)),
|
|
|
|
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
|
|
|
// items: items,
|
|
|
|
limited: this.object.limited,
|
|
|
|
options: this.options,
|
|
|
|
owner: this.document.isOwner,
|
|
|
|
itemsByType: Misc.classify(this.object.items.map(i => foundry.utils.deepClone(i.data))),
|
|
|
|
};
|
2020-12-01 22:18:15 +01:00
|
|
|
|
2021-03-17 01:21:37 +01:00
|
|
|
RdDUtility.filterItemsPerTypeForSheet(formData);
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2021-03-17 01:21:37 +01:00
|
|
|
formData.options.isGM = game.user.isGM;
|
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
if (formData.type == 'creature') return formData; // Shortcut
|
2021-03-17 01:21:37 +01:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
formData.competenceByCategory = Misc.classify(formData.competences, it => it.data.categorie);
|
2021-03-17 01:21:37 +01:00
|
|
|
|
|
|
|
formData.calc = {
|
2021-03-25 03:18:27 +01:00
|
|
|
comptageArchetype: RdDItemCompetence.computeResumeArchetype(formData.competences),
|
|
|
|
competenceXPTotal: RdDItemCompetence.computeTotalXP(formData.competences),
|
2021-03-17 01:21:37 +01:00
|
|
|
caracTotal: RdDCarac.computeTotal(formData.data.carac, formData.data.beaute),
|
|
|
|
// Mise à jour de l'encombrement total et du prix de l'équipement
|
|
|
|
encTotal: await this.actor.computeEncombrementTotalEtMalusArmure(),
|
2021-04-01 21:31:13 +02:00
|
|
|
prixTotalEquipement: this.actor.computePrixTotalEquipement(),
|
2021-03-17 01:21:37 +01:00
|
|
|
surprise: RdDBonus.find(this.actor.getSurprise(false)).descr,
|
|
|
|
fatigue: {
|
|
|
|
malus: RdDUtility.calculMalusFatigue(formData.data.sante.fatigue.value, formData.data.sante.endurance.max),
|
|
|
|
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(formData.data.sante.fatigue.value, formData.data.sante.endurance.max).html() + "</table>"
|
|
|
|
},
|
|
|
|
resumeBlessures: this.actor.computeResumeBlessure(formData.data.blessures),
|
|
|
|
};
|
|
|
|
formData.calc.surEncombrementMessage = (formData.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
|
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
formData.competences.forEach(item => {
|
2021-03-17 01:21:37 +01:00
|
|
|
item.visible = !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item);
|
|
|
|
RdDItemCompetence.levelUp(item);
|
|
|
|
});
|
2021-03-16 22:56:57 +01:00
|
|
|
|
2021-03-17 01:21:37 +01:00
|
|
|
Object.values(formData.data.carac).forEach(c => {
|
|
|
|
RdDCarac.levelUp(c);
|
|
|
|
});
|
2021-01-03 19:19:02 +01:00
|
|
|
|
2020-08-13 22:28:56 +02:00
|
|
|
|
2021-03-18 23:55:26 +01:00
|
|
|
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
2021-03-25 03:18:27 +01:00
|
|
|
formData.combat = duplicate(formData.armes ?? []);
|
|
|
|
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences);
|
|
|
|
RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.data.carac);
|
|
|
|
formData.esquive = RdDItemCompetence.getEsquive(formData.competences);
|
|
|
|
formData.combat = RdDCombatManager.finalizeArmeList(formData.combat, formData.competences, formData.data.carac);
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2021-03-25 03:18:27 +01:00
|
|
|
this.armesList = formData.combat;
|
2021-03-15 00:05:56 +01:00
|
|
|
|
2020-11-12 14:43:08 +01:00
|
|
|
// Common data
|
2021-03-16 22:56:57 +01:00
|
|
|
formData.ajustementsConditions = CONFIG.RDD.ajustementsConditions;
|
|
|
|
formData.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-11-12 14:43:08 +01:00
|
|
|
// low is normal, this the base used to compute the grid.
|
2021-03-25 03:18:27 +01:00
|
|
|
formData.fatigue = {
|
2021-03-16 22:56:57 +01:00
|
|
|
malus: RdDUtility.calculMalusFatigue(formData.data.sante.fatigue.value, formData.data.sante.endurance.max),
|
|
|
|
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(formData.data.sante.fatigue.value, formData.data.sante.endurance.max).html() + "</table>"
|
2021-01-08 22:23:50 +01:00
|
|
|
}
|
|
|
|
|
2021-03-18 23:55:26 +01:00
|
|
|
formData.hautreve = {
|
|
|
|
sortsReserve: formData.data.reve.reserve.list,
|
|
|
|
rencontres: duplicate(formData.data.reve.rencontre.list),
|
2021-04-28 00:48:39 +02:00
|
|
|
casesTmr: formData.itemsByType.casetmr,
|
|
|
|
cacheTMR: this.actor.isTMRCache()
|
2021-03-18 23:55:26 +01:00
|
|
|
}
|
|
|
|
|
2021-03-16 22:56:57 +01:00
|
|
|
RdDUtility.buildArbreDeConteneur(this, formData);
|
2021-03-18 23:55:26 +01:00
|
|
|
formData.subacteurs = {
|
|
|
|
vehicules: this.actor.listeVehicules(),
|
|
|
|
montures: this.actor.listeMontures(),
|
|
|
|
suivants: this.actor.listeSuivants()
|
|
|
|
}
|
2021-04-04 00:16:49 +02:00
|
|
|
if (this.actor.getBestDraconic().data.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-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
|
|
|
/* -------------------------------------------- */
|
|
|
|
async _onDrop(event) {
|
2021-04-13 21:30:02 +02:00
|
|
|
let toSuper = await this.actor.processItemDropEvent(event, this.objetVersConteneur);
|
2021-03-15 00:05:56 +01:00
|
|
|
if (toSuper) {
|
2021-01-09 09:54:08 +01:00
|
|
|
super._onDrop(event);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2020-12-15 22:44:49 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-08 22:23:50 +01:00
|
|
|
async creerObjet() {
|
2021-03-31 00:11:35 +02:00
|
|
|
let itemType = $(".item-type").val();
|
2021-03-25 03:18:27 +01:00
|
|
|
await this.createItem('Nouveau ' + itemType, itemType);
|
2020-12-15 22:44:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-01-08 22:23:50 +01:00
|
|
|
async selectObjetType() {
|
2021-04-06 23:36:35 +02:00
|
|
|
let typeObjets = RdDItem.getTypeObjetsEquipement();
|
2021-03-31 00:11:35 +02:00
|
|
|
let options = `<span class="competence-label">Selectionnez le type d'équipement</span><select class="item-type">`;
|
|
|
|
for (let typeName of typeObjets) {
|
|
|
|
options += `<option value="${typeName}">${typeName}</option>`
|
2020-12-15 22:44:49 +01:00
|
|
|
}
|
|
|
|
options += '</select>';
|
2021-01-08 22:23:50 +01:00
|
|
|
let d = new Dialog({
|
|
|
|
title: "Créer un équipement",
|
|
|
|
content: options,
|
|
|
|
buttons: {
|
|
|
|
one: {
|
2020-12-15 22:44:49 +01:00
|
|
|
icon: '<i class="fas fa-check"></i>',
|
|
|
|
label: "Créer l'objet",
|
|
|
|
callback: () => this.creerObjet()
|
|
|
|
}
|
2021-01-08 22:23:50 +01:00
|
|
|
}
|
|
|
|
});
|
2020-12-15 22:44:49 +01:00
|
|
|
d.render(true);
|
|
|
|
}
|
2021-04-13 00:58:05 +02:00
|
|
|
|
2021-03-31 00:11:35 +02:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
async selectTypeOeuvre() {
|
2021-04-06 23:36:35 +02:00
|
|
|
let typeOeuvres = RdDItem.getTypesOeuvres();
|
2021-03-31 00:11:35 +02:00
|
|
|
let options = `<span class="competence-label">Selectionnez le type d'oeuvre</span><select class="item-type">`;
|
|
|
|
for (let typeName of typeOeuvres) {
|
|
|
|
options += `<option value="${typeName}">${typeName}</option>`
|
|
|
|
}
|
|
|
|
options += '</select>';
|
|
|
|
let d = new Dialog({
|
|
|
|
title: "Créer une oeuvre",
|
|
|
|
content: options,
|
|
|
|
buttons: {
|
|
|
|
one: {
|
|
|
|
icon: '<i class="fas fa-check"></i>',
|
|
|
|
label: "Créer l'oeuvre",
|
|
|
|
callback: () => this.creerObjet()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
d.render(true);
|
|
|
|
}
|
2020-11-10 13:53:51 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-05-21 21:48:20 +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
|
|
|
|
2020-12-20 02:05:47 +01:00
|
|
|
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
|
2020-12-01 01:17:18 +01:00
|
|
|
|
2021-01-26 18:57:15 +01:00
|
|
|
html.find('#show-hide-competences').click((event) => {
|
|
|
|
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
|
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
|
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-04-13 00:58:05 +02:00
|
|
|
html.find('.item-split').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
const item = this.actor.items.get(li.data("item-id"));
|
|
|
|
this.splitItem(item);
|
|
|
|
});
|
2020-05-21 21:48:20 +02:00
|
|
|
html.find('.item-edit').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
2021-03-25 09:28:36 +01:00
|
|
|
const item = this.actor.items.get(li.data("item-id"));
|
2020-05-21 21:48:20 +02:00
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
2021-02-08 14:15:18 +01:00
|
|
|
// Update Inventory Item
|
|
|
|
html.find('.rencontre-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
const rencontreKey = li.data("item-id");
|
|
|
|
this.actor.deleteTMRRencontre(rencontreKey);
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
// Delete Inventory Item
|
|
|
|
html.find('.item-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
2021-01-11 16:29:41 +01:00
|
|
|
RdDUtility.confirmerSuppression(this, li);
|
2021-03-15 00:05:56 +01:00
|
|
|
});
|
2021-04-12 00:16:23 +02:00
|
|
|
html.find('.item-action').click(ev => {
|
2021-04-06 23:44:57 +02:00
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
const itemId = li.data("item-id");
|
|
|
|
const item = this.actor.getObjet(itemId);
|
2021-04-12 00:16:23 +02:00
|
|
|
this.actor.actionItem(item);
|
2021-04-06 23:44:57 +02:00
|
|
|
});
|
2021-01-11 16:29:41 +01:00
|
|
|
html.find('.subacteur-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
RdDUtility.confirmerSuppressionSubacteur(this, li);
|
|
|
|
});
|
2021-03-15 00:05:56 +01:00
|
|
|
|
2021-04-11 12:05:06 +02:00
|
|
|
html.find('.encaisser-direct').click(ev => {
|
2020-12-27 19:55:51 +01:00
|
|
|
this.actor.encaisser();
|
2020-11-07 21:06:37 +01:00
|
|
|
});
|
|
|
|
|
2021-01-19 23:39:35 +01:00
|
|
|
html.find('.remise-a-neuf').click(ev => {
|
2020-12-01 01:17:18 +01:00
|
|
|
if (game.user.isGM) {
|
|
|
|
this.actor.remiseANeuf();
|
2021-01-19 23:39:35 +01:00
|
|
|
ev.preventDefault();
|
2020-12-01 01:17:18 +01:00
|
|
|
}
|
|
|
|
});
|
2021-03-31 00:11:35 +02:00
|
|
|
html.find('.creer-tache').click(ev => {
|
2020-12-15 08:37:52 +01:00
|
|
|
this.createEmptyTache();
|
|
|
|
});
|
2021-03-31 00:11:35 +02:00
|
|
|
html.find('.creer-un-objet').click(ev => {
|
2020-12-15 22:44:49 +01:00
|
|
|
this.selectObjetType();
|
|
|
|
});
|
2021-03-31 00:11:35 +02:00
|
|
|
html.find('.creer-une-oeuvre').click(ev => {
|
|
|
|
this.selectTypeOeuvre();
|
|
|
|
});
|
2021-01-08 11:56:10 +01:00
|
|
|
html.find('#nettoyer-conteneurs').click(ev => {
|
|
|
|
this.actor.nettoyerConteneurs();
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-07-27 16:27:41 +02:00
|
|
|
// Blessure control
|
|
|
|
html.find('.blessure-control').click(ev => {
|
2021-01-08 22:23:50 +01:00
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let btype = li.data("blessure-type");
|
|
|
|
let index = li.data('blessure-index');
|
2020-07-27 16:27:41 +02:00
|
|
|
let active = $(ev.currentTarget).data('blessure-active');
|
|
|
|
//console.log(btype, index, active);
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.manageBlessureFromSheet(btype, index, active).then(this.render(true));
|
2020-07-27 16:27:41 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Blessure data
|
|
|
|
html.find('.blessures-soins').change(ev => {
|
2021-01-08 22:23:50 +01:00
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let btype = li.data('blessure-type');
|
|
|
|
let index = li.data('blessure-index');
|
|
|
|
let psoins = li.find('input[name=premiers_soins]').val();
|
2020-07-27 16:27:41 +02:00
|
|
|
let pcomplets = li.find('input[name=soins_complets]').val();
|
2021-01-08 22:23:50 +01:00
|
|
|
let jours = li.find('input[name=jours]').val();
|
|
|
|
let loc = li.find('input[name=localisation]').val();
|
2020-07-27 16:27:41 +02:00
|
|
|
//console.log(btype, index, psoins, pcomplets, jours, loc);
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then(this.render(true));
|
2020-07-20 12:02:07 +02:00
|
|
|
});
|
|
|
|
|
2020-06-23 23:34:12 +02:00
|
|
|
// Equip Inventory Item
|
|
|
|
html.find('.item-equip').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
2020-11-05 20:23:16 +01:00
|
|
|
this.actor.equiperObjet(li.data("item-id"));
|
2020-06-23 23:34:12 +02:00
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
|
2020-06-12 22:46:04 +02:00
|
|
|
// Roll Carac
|
|
|
|
html.find('.carac-label a').click((event) => {
|
|
|
|
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-03-18 01:04:41 +01:00
|
|
|
html.find('.chance-actuelle').click((event) => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.rollCarac('chance-actuelle');
|
2020-12-06 18:41:54 +01:00
|
|
|
});
|
|
|
|
|
2021-03-18 01:04:41 +01:00
|
|
|
html.find('.chance-appel').click((event) => {
|
2020-12-06 23:31:23 +01:00
|
|
|
this.actor.rollAppelChance();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
|
2020-12-11 08:29:24 +01:00
|
|
|
html.find('#jet-astrologie').click((event) => {
|
|
|
|
this.actor.astrologieNombresAstraux();
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-05-22 22:37:02 +02:00
|
|
|
// Roll Skill
|
|
|
|
html.find('.competence-label a').click((event) => {
|
|
|
|
let compName = event.currentTarget.text;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.rollCompetence(compName);
|
2020-05-22 22:37:02 +02:00
|
|
|
});
|
2020-12-15 08:37:52 +01:00
|
|
|
html.find('.tache-label a').click((event) => {
|
2021-01-08 22:23:50 +01:00
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let tacheId = li.data('item-id');
|
|
|
|
this.actor.rollTache(tacheId);
|
2020-12-15 08:37:52 +01:00
|
|
|
});
|
2021-01-04 22:03:00 +01:00
|
|
|
html.find('.meditation-label a').click((event) => {
|
2021-01-08 22:23:50 +01:00
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let meditationId = li.data('item-id');
|
|
|
|
this.actor.rollMeditation(meditationId);
|
2021-01-04 22:03:00 +01:00
|
|
|
});
|
2021-01-27 23:35:45 +01:00
|
|
|
html.find('.chant-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let chantId = li.data('item-id');
|
|
|
|
this.actor.rollChant(chantId);
|
|
|
|
});
|
|
|
|
html.find('.danse-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let danseId = li.data('item-id');
|
|
|
|
this.actor.rollDanse(danseId);
|
|
|
|
});
|
|
|
|
html.find('.musique-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let musiqueId = li.data('item-id');
|
|
|
|
this.actor.rollMusique(musiqueId);
|
|
|
|
});
|
2021-02-06 01:34:01 +01:00
|
|
|
html.find('.oeuvre-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let oeuvreId = li.data('item-id');
|
|
|
|
this.actor.rollOeuvre(oeuvreId);
|
|
|
|
});
|
2021-01-27 23:35:45 +01:00
|
|
|
html.find('.jeu-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let jeuId = li.data('item-id');
|
|
|
|
this.actor.rollJeu(jeuId);
|
|
|
|
});
|
|
|
|
html.find('.recettecuisine-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let recetteId = li.data('item-id');
|
|
|
|
this.actor.rollRecetteCuisine(recetteId);
|
|
|
|
});
|
2021-01-11 16:29:41 +01:00
|
|
|
html.find('.subacteur-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
let actorId = li.data('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-04-28 00:48:39 +02:00
|
|
|
|
|
|
|
// Boutons spéciaux MJs
|
|
|
|
html.find('.forcer-tmr-aleatoire').click((event) => {
|
|
|
|
this.actor.cacheTMRetMessage();
|
|
|
|
});
|
|
|
|
html.find('.afficher-tmr').click((event) => {
|
|
|
|
this.actor.afficheTMRetMessage();
|
|
|
|
});
|
|
|
|
|
2020-11-15 12:26:19 +01:00
|
|
|
// Points de reve actuel
|
|
|
|
html.find('.ptreve-actuel a').click((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
|
2020-06-07 23:16:29 +02:00
|
|
|
html.find('.arme-label a').click((event) => {
|
|
|
|
let armeName = event.currentTarget.text;
|
2020-11-23 20:40:56 +01:00
|
|
|
let competenceName = event.currentTarget.attributes['data-competence-name'].value;
|
2020-12-08 03:04:00 +01:00
|
|
|
this.actor.rollArme(competenceName, armeName);
|
2020-06-07 23:16:29 +02:00
|
|
|
});
|
2020-12-05 21:24:31 +01:00
|
|
|
// Initiative pour l'arme
|
|
|
|
html.find('.arme-initiative a').click((event) => {
|
2021-01-08 22:23:50 +01:00
|
|
|
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
|
|
|
|
if (combatant) {
|
2020-12-05 21:24:31 +01:00
|
|
|
let armeName = event.currentTarget.attributes['data-arme-name'].value;
|
2021-01-08 22:23:50 +01:00
|
|
|
let arme = this.armesList.find(a => a.name == armeName);
|
2021-02-25 02:13:39 +01:00
|
|
|
RdDCombatManager.rollInitiativeCompetence(combatant._id, arme);
|
2020-12-05 21:24:31 +01:00
|
|
|
} else {
|
|
|
|
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
|
|
|
|
}
|
|
|
|
});
|
2020-12-30 15:56:17 +01:00
|
|
|
// Display TMR, visuualisation
|
2021-04-11 12:05:06 +02:00
|
|
|
html.find('.visu-tmr').click((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-04-11 12:05:06 +02:00
|
|
|
html.find('.monte-tmr').click((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-04-11 12:05:06 +02:00
|
|
|
html.find('.monte-tmr-rapide').click((event) => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.displayTMR("rapide");
|
2020-07-24 10:51:11 +02:00
|
|
|
});
|
|
|
|
|
2021-04-11 12:05:06 +02:00
|
|
|
html.find('.dormir-une-heure').click((event) => {
|
2020-11-16 04:32:42 +01:00
|
|
|
this.actor.dormir(1);
|
2020-11-24 18:54:13 +01:00
|
|
|
});
|
2021-04-11 12:05:06 +02:00
|
|
|
html.find('.dormir-chateau-dormant').click((event) => {
|
2020-11-24 18:54:13 +01:00
|
|
|
this.actor.dormirChateauDormant();
|
|
|
|
});
|
2021-04-11 12:05:06 +02:00
|
|
|
html.find('.enlever-tous-effets').click((event) => {
|
2021-01-13 03:42:13 +01:00
|
|
|
this.actor.enleverTousLesEffets();
|
|
|
|
});
|
2020-07-24 10:51:11 +02:00
|
|
|
// Display info about queue
|
|
|
|
html.find('.queuesouffle-label a').click((event) => {
|
2020-07-27 16:27:41 +02:00
|
|
|
let myID = event.currentTarget.attributes['data-item-id'].value;
|
2021-03-30 21:56:18 +02:00
|
|
|
const item = this.actor.getEmbeddedDocument('Item', myID);
|
2020-07-24 10:51:11 +02:00
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
2020-12-30 19:18:07 +01:00
|
|
|
// Info sort
|
2020-07-05 21:45:25 +02:00
|
|
|
html.find('.sort-label a').click((event) => {
|
2020-07-24 10:51:11 +02:00
|
|
|
let myID = event.currentTarget.attributes['data-id'].value;
|
2021-03-30 21:56:18 +02:00
|
|
|
const item = this.actor.getEmbeddedDocument('Item', myID);
|
2020-12-30 19:18:07 +01:00
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
|
|
|
// Info sort
|
|
|
|
html.find('.case-label a').click((event) => {
|
|
|
|
let myID = event.currentTarget.attributes['data-id'].value;
|
2021-03-30 21:56:18 +02:00
|
|
|
const item = this.actor.getEmbeddedDocument('Item', myID);
|
2020-07-24 10:51:11 +02:00
|
|
|
item.sheet.render(true);
|
2020-07-05 21:45:25 +02:00
|
|
|
});
|
2020-07-24 10:51:11 +02:00
|
|
|
|
2020-12-01 22:18:15 +01:00
|
|
|
// Display info about queue
|
|
|
|
html.find('.conteneur-name a').click((event) => {
|
|
|
|
let myID = event.currentTarget.attributes['data-item-id'].value;
|
2021-01-08 22:23:50 +01:00
|
|
|
RdDUtility.toggleAfficheContenu(myID);
|
2020-12-01 22:18:15 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-11-20 12:06:54 +01:00
|
|
|
if (this.options.editCaracComp) {
|
|
|
|
// On carac change
|
|
|
|
html.find('.carac-value').change((event) => {
|
|
|
|
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
|
|
|
|
//console.log("Value changed :", event, caracName);
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCarac(caracName, parseInt(event.target.value));
|
|
|
|
});
|
2021-01-03 18:19:18 +01:00
|
|
|
html.find('.carac-xp').change((event) => {
|
|
|
|
let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", "");
|
|
|
|
//console.log("Value changed :", event, caracName);
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
|
|
|
|
});
|
2020-11-20 12:06:54 +01:00
|
|
|
// On competence change
|
|
|
|
html.find('.competence-value').change((event) => {
|
|
|
|
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
|
|
|
|
html.find('.competence-xp').change((event) => {
|
|
|
|
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
|
|
|
|
html.find('.competence-xp-sort').change((event) => {
|
|
|
|
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
|
|
|
|
html.find('.competence-archetype').change((event) => {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Gestion du bouton lock/unlock
|
2020-12-06 22:19:40 +01:00
|
|
|
html.find('.lock-unlock-sheet').click((event) => {
|
2020-11-20 12:06:54 +01:00
|
|
|
this.options.editCaracComp = !this.options.editCaracComp;
|
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-03 19:19:02 +01:00
|
|
|
html.find('#show-hide-archetype').click((event) => {
|
|
|
|
this.options.montrerArchetype = !this.options.montrerArchetype;
|
2020-12-06 22:19:40 +01: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
|
|
|
|
html.find('.pointsreve-value').change((event) => {
|
|
|
|
let reveValue = event.currentTarget.value;
|
2021-03-22 20:10:37 +01:00
|
|
|
this.actor.update({ "data.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
|
|
|
|
html.find('.seuil-reve-value').change((event) => {
|
|
|
|
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
|
|
|
|
2020-12-18 01:10:03 +01:00
|
|
|
html.find('#attribut-protection-edit').change((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
|
|
|
|
html.find('.compteur-edit').change((event) => {
|
|
|
|
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
|
|
|
|
|
|
|
html.find('#ethylisme').change((event) => {
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.setEthylisme(parseInt(event.target.value));
|
|
|
|
});
|
2021-03-18 01:04:41 +01:00
|
|
|
html.find('.stress-test').click((event) => {
|
2021-01-29 12:08:02 +01:00
|
|
|
this.actor.transformerStress();
|
2020-08-29 22:52:41 +02:00
|
|
|
this.render(true);
|
|
|
|
});
|
2021-03-16 21:49:21 +01:00
|
|
|
html.find('.moral-malheureux').click((event) => {
|
2020-12-16 02:54:28 +01:00
|
|
|
this.actor.jetDeMoral('malheureuse');
|
|
|
|
this.render(true);
|
|
|
|
});
|
2021-03-16 21:49:21 +01:00
|
|
|
html.find('.moral-neutre').click((event) => {
|
2020-12-16 02:54:28 +01:00
|
|
|
this.actor.jetDeMoral('neutre');
|
|
|
|
this.render(true);
|
|
|
|
});
|
2021-03-16 21:49:21 +01:00
|
|
|
html.find('.moral-heureux').click((event) => {
|
2020-12-16 02:54:28 +01:00
|
|
|
this.actor.jetDeMoral('heureuse');
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-12-06 20:11:30 +01:00
|
|
|
html.find('#ethylisme-test').click((event) => {
|
2021-04-06 23:39:27 +02:00
|
|
|
this.actor.jetEthylisme();
|
2020-12-06 20:11:30 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
2020-12-06 21:39:55 +01:00
|
|
|
|
|
|
|
html.find('#jet-vie').click((event) => {
|
|
|
|
this.actor.jetVie();
|
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-29 16:58:45 +01:00
|
|
|
html.find('#jet-endurance').click((event) => {
|
|
|
|
this.actor.jetEndurance();
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-12-31 00:55:02 +01:00
|
|
|
|
|
|
|
html.find('.monnaie-plus').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.monnaieIncDec(li.data("item-id"), 1);
|
2020-12-31 00:55:02 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
html.find('.monnaie-moins').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.monnaieIncDec(li.data("item-id"), -1);
|
2020-12-31 00:55:02 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-06-23 23:34:12 +02:00
|
|
|
html.find('#vie-plus').click((event) => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("vie", 1);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-06-23 23:34:12 +02:00
|
|
|
html.find('#vie-moins').click((event) => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("vie", -1);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-06-23 23:34:12 +02:00
|
|
|
html.find('#endurance-plus').click((event) => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("endurance", 1);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-06-23 23:34:12 +02:00
|
|
|
html.find('#endurance-moins').click((event) => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("endurance", -1);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-13 03:42:13 +01:00
|
|
|
html.find('.data-sante-sonne').click((event) => {
|
|
|
|
this.actor.setSonne(event.currentTarget.checked);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-11-18 18:37:15 +01:00
|
|
|
html.find('#ptreve-actuel-plus').click((event) => {
|
2020-11-27 10:21:20 +01:00
|
|
|
this.actor.reveActuelIncDec(1);
|
2020-11-18 18:37:15 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
2020-11-17 19:29:18 +01:00
|
|
|
html.find('#ptreve-actuel-moins').click((event) => {
|
2020-11-27 10:21:20 +01:00
|
|
|
this.actor.reveActuelIncDec(-1);
|
2020-11-17 19:29:18 +01:00
|
|
|
this.render(true);
|
|
|
|
});
|
2020-06-23 23:34:12 +02:00
|
|
|
html.find('#fatigue-plus').click((event) => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("fatigue", 1);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-06-23 23:34:12 +02:00
|
|
|
html.find('#fatigue-moins').click((event) => {
|
2020-05-28 23:36:09 +02:00
|
|
|
this.actor.santeIncDec("fatigue", -1);
|
|
|
|
this.render(true);
|
|
|
|
});
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|
2021-01-08 22:23:50 +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);
|
|
|
|
const sheetBody = this.element.find(".sheet-body");
|
|
|
|
const bodyHeight = position.height - 192;
|
|
|
|
sheetBody.css("height", bodyHeight);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
_updateObject(event, formData) {
|
|
|
|
// Update the Actor
|
|
|
|
return this.object.update(formData);
|
|
|
|
}
|
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) {
|
|
|
|
const itemData = Misc.data(item);
|
|
|
|
if (split >= 1 && split < itemData.data.quantite) {
|
|
|
|
await item.diminuerQuantite(split);
|
|
|
|
itemData.data.quantite = split;
|
|
|
|
itemData.id = undefined;
|
|
|
|
await this.actor.createEmbeddedDocuments('Item', [itemData])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|