foundryvtt-reve-de-dragon/module/actor-sheet.js

564 lines
21 KiB
JavaScript
Raw Normal View History

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";
import { HtmlUtility } from "./html-utility.js";
import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
import { RdDBonus } from "./rdd-bonus.js";
import { Misc } from "./misc.js";
import { RdDCombatManager } from "./rdd-combat.js";
import { RdDCarac } from "./rdd-carac.js";
2021-04-13 00:58:05 +02:00
import { DialogSplitItem } from "./dialog-split-item.js";
2021-05-08 20:08:56 +02:00
import { ReglesOptionelles } from "./regles-optionelles.js";
2021-06-26 00:55:54 +02:00
import { DialogRepos } from "./dialog-repos.js";
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
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 */
static get defaultOptions() {
RdDUtility.initAfficheContenu();
return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
width: 640,
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,
showCompNiveauBase: false,
vueDetaillee: false
2020-05-21 21:48:20 +02:00
});
}
/* -------------------------------------------- */
async getData() {
2021-03-25 03:18:27 +01:00
const objectData = Misc.data(this.object);
2021-06-02 17:39:16 +02:00
//this.actor.checkMonnaiePresence(this.actor.data.items); // Always check
2021-03-25 03:18:27 +01:00
let formData = {
title: this.title,
id: objectData.id,
type: objectData.type,
img: objectData.img,
name: objectData.name,
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)),
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner,
itemsByType: Misc.classify(this.object.items.map(i => foundry.utils.deepClone(i.data))),
};
RdDUtility.filterItemsPerTypeForSheet(formData);
formData.options.isGM = game.user.isGM;
2021-03-25 03:18:27 +01:00
if (formData.type == 'creature') return formData; // Shortcut
2021-03-25 03:18:27 +01:00
formData.competenceByCategory = Misc.classify(formData.competences, it => it.data.categorie);
formData.calc = {
2021-03-25 03:18:27 +01:00
comptageArchetype: RdDItemCompetence.computeResumeArchetype(formData.competences),
competenceXPTotal: RdDItemCompetence.computeTotalXP(formData.competences),
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(),
surprise: RdDBonus.find(this.actor.getSurprise(false)).descr,
2021-05-08 20:08:56 +02:00
fatigue: RdDUtility.calculFatigueHtml(formData.data.sante.fatigue.value, formData.data.sante.endurance.max),
resumeBlessures: this.actor.computeResumeBlessure(formData.data.blessures),
2021-12-05 21:18:00 +01:00
surEncombrementMessage: this.actor.getMessageSurEncombrement()
};
2021-03-25 03:18:27 +01:00
formData.competences.forEach(item => {
item.visible = this.options.cherchercompetence
? RdDItemCompetence.nomContientTexte(item, this.options.cherchercompetence)
2022-01-01 14:01:41 +01:00
: (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value);
});
2021-03-16 22:56:57 +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
// 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.esquives = this.actor.getCompetences("Esquive").map(i => foundry.utils.deepClone(i.data));
2021-03-25 03:18:27 +01:00
formData.combat = RdDCombatManager.finalizeArmeList(formData.combat, formData.competences, formData.data.carac);
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;
formData.hautreve = {
2021-06-29 00:56:25 +02:00
isDemiReve: this.actor.getEffectByLabel("Demi-rêve"),
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-05-07 01:47:51 +02:00
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
formData.subacteurs = {
vehicules: this.actor.listeVehicules(),
montures: this.actor.listeMontures(),
suivants: this.actor.listeSuivants()
}
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
}
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) {
2021-12-05 16:48:18 +01:00
console.log("_onDropActor", this.actor.id, dragData);
this.actor.addSubActeur(dragData.id || dragData.data._id);
2021-05-07 01:47:51 +02:00
super._onDropActor(event, dragData);
}
2022-01-01 14:01:41 +01:00
2021-05-07 01:47:51 +02:00
/* -------------------------------------------- */
async _onDropItem(event, dragData) {
const destItemId = $(event.target)?.closest('.item').attr('data-item-id');
2021-12-05 16:48:18 +01:00
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 });
}
/* -------------------------------------------- */
async createEmptyTache() {
2021-03-25 03:18:27 +01:00
await this.createItem('Nouvelle tache', 'tache');
}
/* -------------------------------------------- */ /** @override */
activateListeners(html) {
2020-05-21 21:48:20 +02:00
super.activateListeners(html);
2020-12-20 02:05:47 +01:00
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
2021-05-08 20:08:56 +02:00
HtmlUtility._showControlWhen($(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
2020-05-21 21:48:20 +02:00
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
html.find('.item-split').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
RdDSheetUtility.splitItem(item, this.actor);
2021-04-13 00:58:05 +02:00
});
html.find('.item-edit').click(async event => {
2022-05-14 17:28:27 +02:00
const item = RdDSheetUtility.getItem(event, this.actor)
console.log("ITEM :", item)
item.sheet.render(true)
})
html.find('.display-label a').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
item.sheet.render(true);
});
html.find('.rencontre-delete').click(async event => {
this.actor.deleteTMRRencontre(RdDSheetUtility.getItemId(event));
});
html.find('.item-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event);
RdDUtility.confirmerSuppression(this, li);
2021-03-15 00:05:56 +01:00
});
html.find('.item-vendre').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
2021-05-07 17:27:02 +02:00
item?.proposerVente();
});
html.find('.item-montrer').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
item?.postItem();
});
html.find('.item-action').click(async event => {
2022-05-14 17:28:27 +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
});
html.find('.subacteur-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event);
RdDUtility.confirmerSuppressionSubacteur(this, li);
});
2021-03-15 00:05:56 +01:00
html.find('.encaisser-direct').click(async event => {
this.actor.encaisser();
2022-05-14 17:28:27 +02:00
})
html.find('.sheet-possession-attack').click(async event => {
const poss = RdDSheetUtility.getItem(event, this.actor)
this.actor.conjurerPossession(poss)
})
html.find('.remise-a-neuf').click(async event => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
});
html.find('.creer-tache').click(async event => {
this.createEmptyTache();
});
html.find('.creer-un-objet').click(async event => {
2022-01-01 14:01:41 +01:00
RdDUtility.selectObjetType(this);
});
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
});
html.find('#nettoyer-conteneurs').click(async event => {
2021-01-08 11:56:10 +01:00
this.actor.nettoyerConteneurs();
});
// Blessure control
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');
//console.log(btype, index, active);
await this.actor.manageBlessureFromSheet(btype, index, active);
});
// Blessure data
html.find('.blessures-soins').change(async event => {
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
html.find('.item-equip').click(async event => {
this.actor.equiperObjet(RdDSheetUtility.getItemId(event));
2020-06-23 23:34:12 +02:00
});
2020-06-12 22:46:04 +02:00
// Roll Carac
html.find('.carac-label a').click(async event => {
2020-06-12 22:46:04 +02:00
let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac(caracName.toLowerCase());
2020-06-12 22:46:04 +02:00
});
html.find('.chance-actuelle').click(async event => {
this.actor.rollCarac('chance-actuelle');
});
html.find('.chance-appel').click(async event => {
this.actor.rollAppelChance();
});
html.find('#jet-astrologie').click(async event => {
2020-12-11 08:29:24 +01:00
this.actor.astrologieNombresAstraux();
});
2020-05-22 22:37:02 +02:00
// Roll Skill
html.find('a.competence-label').click(async event => {
this.actor.rollCompetence(RdDSheetUtility.getItemId(event));
2020-05-22 22:37:02 +02:00
});
html.find('.tache-label a').click(async event => {
this.actor.rollTache(RdDSheetUtility.getItemId(event));
});
html.find('.meditation-label a').click(async event => {
this.actor.rollMeditation(RdDSheetUtility.getItemId(event));
});
html.find('.chant-label a').click(async event => {
this.actor.rollChant(RdDSheetUtility.getItemId(event));
2021-01-27 23:35:45 +01:00
});
html.find('.danse-label a').click(async event => {
this.actor.rollDanse(RdDSheetUtility.getItemId(event));
2021-01-27 23:35:45 +01:00
});
html.find('.musique-label a').click(async event => {
this.actor.rollMusique(RdDSheetUtility.getItemId(event));
2021-01-27 23:35:45 +01:00
});
html.find('.oeuvre-label a').click(async event => {
this.actor.rollOeuvre(RdDSheetUtility.getItemId(event));
});
html.find('.jeu-label a').click(async event => {
this.actor.rollJeu(RdDSheetUtility.getItemId(event));
2021-01-27 23:35:45 +01:00
});
html.find('.recettecuisine-label a').click(async event => {
this.actor.rollRecetteCuisine(RdDSheetUtility.getItemId(event));
2021-01-27 23:35:45 +01:00
});
html.find('.subacteur-label a').click(async event => {
let actorId = RdDSheetUtility.getEventItemData(event, 'actor-id');
2021-03-15 00:05:56 +01:00
let actor = game.actors.get(actorId);
if (actor) {
actor.sheet.render(true);
}
});
2021-04-28 00:48:39 +02:00
// Boutons spéciaux MJs
html.find('.forcer-tmr-aleatoire').click(async event => {
2021-04-28 00:48:39 +02:00
this.actor.cacheTMRetMessage();
});
html.find('.afficher-tmr').click(async event => {
2021-04-28 00:48:39 +02:00
this.actor.afficheTMRetMessage();
});
// Points de reve actuel
html.find('.ptreve-actuel a').click(async event => {
this.actor.rollCarac('reve-actuel');
2020-12-06 21:56:59 +01:00
});
// Roll Weapon1
html.find('.arme-label a').click(async event => {
2021-11-23 02:04:00 +01:00
let arme = this._getEventArmeCombat(event);
2022-01-01 14:01:41 +01:00
this.actor.rollArme(duplicate(arme));
2020-06-07 23:16:29 +02:00
});
// Initiative pour l'arme
html.find('.arme-initiative a').click(async event => {
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
if (combatant) {
2021-11-23 02:04:00 +01:00
let arme = this._getEventArmeCombat(event);
RdDCombatManager.rollInitiativeCompetence(combatant._id, arme);
} else {
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
}
});
// Display TMR, visualisation
html.find('.visu-tmr').click(async event => {
this.actor.displayTMR("visu");
2020-11-14 20:46:39 +01:00
});
2020-07-25 10:29:28 +02:00
// Display TMR, normal
html.find('.monte-tmr').click(async event => {
this.actor.displayTMR("normal");
2020-07-25 10:29:28 +02:00
});
2020-07-25 10:29:28 +02:00
// Display TMR, fast
html.find('.monte-tmr-rapide').click(async event => {
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);
});
2021-06-29 00:56:25 +02:00
html.find('.delete-active-effect').click(async event => {
let id = $(event.currentTarget).parents(".active-effect").data('id');
this.actor.enleverActiveEffectById(id);
});
html.find('.enlever-tous-effets').click(async event => {
this.actor.enleverTousLesEffets();
});
html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true);
});
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);
});
html.find('.competence-xp-augmenter').click(async event => {
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 => {
this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event));
2021-11-23 02:04:00 +01:00
});
2020-11-20 12:06:54 +01:00
if (this.options.editCaracComp) {
// On carac change
html.find('.carac-value').change(async event => {
2020-11-20 12:06:54 +01:00
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
//console.log("Value changed :", event, caracName);
this.actor.updateCarac(caracName, parseInt(event.target.value));
});
html.find('.carac-xp').change(async event => {
let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", "");
//console.log("Value changed :", event, caracName);
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
});
2020-11-20 12:06:54 +01:00
// On competence change
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);
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(async event => {
2020-11-20 12:06:54 +01:00
let compName = event.currentTarget.attributes.compname.value;
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(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
html.find('.competence-archetype').change(async event => {
2021-01-03 19:19:02 +01:00
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value));
});
2020-11-20 12:06:54 +01:00
}
2022-01-01 14:01:41 +01:00
html.find('.show-hide-competences').click(async event => {
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true);
});
html.find('.lock-unlock-sheet').click(async event => {
2020-11-20 12:06:54 +01:00
this.options.editCaracComp = !this.options.editCaracComp;
this.render(true);
});
html.find('.cherchercompetence').change(async event => {
this.options.cherchercompetence = event.currentTarget.value;
this.render(true);
});
html.find('.vue-detaillee').click(async event => {
console.log("CONTROLS", this.options.vueDetaillee)
this.options.vueDetaillee = !this.options.vueDetaillee;
2021-05-13 00:38:06 +02:00
this.render(true);
});
2020-07-14 22:19:29 +02:00
// On pts de reve change
html.find('.pointsreve-value').change(async event => {
2020-07-14 22:19:29 +02:00
let reveValue = event.currentTarget.value;
this.actor.update({ "data.reve.reve.value": reveValue });
});
2020-11-16 03:52:34 +01:00
// On seuil de reve change
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);
});
2020-07-14 22:19:29 +02:00
html.find('#attribut-protection-edit').change(async event => {
this.actor.updateAttributeValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
});
2020-12-18 01:10:03 +01:00
2020-08-29 22:52:41 +02:00
// On stress change
html.find('.compteur-edit').change(async event => {
2020-08-29 22:52:41 +02:00
let fieldName = event.currentTarget.attributes.name.value;
this.actor.updateCompteurValue(fieldName, parseInt(event.target.value));
});
html.find('#ethylisme').change(async event => {
this.actor.setEthylisme(parseInt(event.target.value));
});
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
});
html.find('.moral-malheureux').click(async event => {
2020-12-16 02:54:28 +01:00
this.actor.jetDeMoral('malheureuse');
});
html.find('.moral-neutre').click(async event => {
2020-12-16 02:54:28 +01:00
this.actor.jetDeMoral('neutre');
});
html.find('.moral-heureux').click(async event => {
2020-12-16 02:54:28 +01:00
this.actor.jetDeMoral('heureuse');
});
html.find('#ethylisme-test').click(async event => {
this.actor.jetEthylisme();
2020-12-06 20:11:30 +01:00
});
2020-12-06 21:39:55 +01:00
html.find('.jet-vie').click(async event => {
2020-12-06 21:39:55 +01:00
this.actor.jetVie();
});
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
html.find('.monnaie-plus').click(async event => {
this.actor.monnaieIncDec(RdDSheetUtility.getItemId(event), 1);
2020-12-31 00:55:02 +01:00
});
html.find('.monnaie-moins').click(async event => {
this.actor.monnaieIncDec(RdDSheetUtility.getItemId(event), -1);
2020-12-31 00:55:02 +01:00
});
html.find('.vie-plus').click(async event => {
2020-05-28 23:36:09 +02:00
this.actor.santeIncDec("vie", 1);
});
html.find('.vie-moins').click(async event => {
2020-05-28 23:36:09 +02:00
this.actor.santeIncDec("vie", -1);
});
html.find('.endurance-plus').click(async event => {
2020-05-28 23:36:09 +02:00
this.actor.santeIncDec("endurance", 1);
});
html.find('.endurance-moins').click(async event => {
2020-05-28 23:36:09 +02:00
this.actor.santeIncDec("endurance", -1);
});
html.find('.ptreve-actuel-plus').click(async event => {
this.actor.reveActuelIncDec(1);
});
html.find('.ptreve-actuel-moins').click(async event => {
this.actor.reveActuelIncDec(-1);
2020-11-17 19:29:18 +01:00
});
html.find('.fatigue-plus').click(async event => {
2020-05-28 23:36:09 +02:00
this.actor.santeIncDec("fatigue", 1);
});
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-11-23 02:04:00 +01:00
_getEventArmeCombat(event) {
const li = $(event.currentTarget)?.parents(".item");
let armeName = li.data("arme-name");
let compName = li.data('competence-name');
const arme = this.armesList.find(a => a.name == armeName && a.data.competence == compName);
if (!arme) {
return { name: armeName, data: { competence: compName } };
}
return arme;
}
2020-05-21 21:48:20 +02:00
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {
2020-05-21 21:48:20 +02:00
const position = super.setPosition(options);
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");
const bodyHeight = position.height - sheetHeader[0].clientHeight - sheetTabs[0].clientHeight;
2020-05-21 21:48:20 +02:00
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) {
2021-05-07 00:06:47 +02:00
if (split >= 1 && split < Misc.data(item).data.quantite) {
2021-04-13 00:58:05 +02:00
await item.diminuerQuantite(split);
const itemData = duplicate(Misc.data(item));
2021-04-13 00:58:05 +02:00
itemData.data.quantite = split;
await this.actor.createEmbeddedDocuments('Item', [itemData])
}
}
2020-05-21 21:48:20 +02:00
}