From 9bc4b9a3ca3256c4c23eb881dd91de047f07ee84 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 24 May 2021 22:12:37 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=A9paration=20ajout=20empoignade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit actor.rollArme prend maintenant une arme (ou structure) plutôt que des noms l'empoignade sera une pseudo arme, comme le corps à corps # Conflicts: # module/actor-sheet.js --- module/actor-sheet.js | 19 ++++++++++++++----- module/actor.js | 8 +++----- module/item-arme.js | 2 +- module/rdd-combat.js | 2 +- module/rdd-hotbar-drop.js | 8 ++++---- module/rdd-token-hud.js | 3 +-- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index d35afefe..8ebde729 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -327,7 +327,7 @@ export class RdDActorSheet extends ActorSheet { actor.sheet.render(true); } }); - + // Boutons spéciaux MJs html.find('.forcer-tmr-aleatoire').click(async event => { this.actor.cacheTMRetMessage(); @@ -335,7 +335,7 @@ export class RdDActorSheet extends ActorSheet { html.find('.afficher-tmr').click(async event => { this.actor.afficheTMRetMessage(); }); - + // Points de reve actuel html.find('.ptreve-actuel a').click(async event => { this.actor.rollCarac('reve-actuel'); @@ -344,8 +344,16 @@ export class RdDActorSheet extends ActorSheet { // Roll Weapon1 html.find('.arme-label a').click(async event => { let armeName = event.currentTarget.text; - let competenceName = event.currentTarget.attributes['data-competence-name'].value; - this.actor.rollArme(competenceName, armeName); + let compName = event.currentTarget.attributes['data-competence-name'].value; + let arme = this.actor.data.find(it => + it.name == armeName && + RdDItemArme.isArme(it) && + ((compName ?? it.data.competence) == it.data.competence) + ); + if (!arme) { + arme = { name: armeName, data: { competence: compName } }; + } + this.actor.rollArme(arme); }); // Initiative pour l'arme html.find('.arme-initiative a').click(async event => { @@ -441,6 +449,7 @@ export class RdDActorSheet extends ActorSheet { this.render(true); }); html.find('.lock-unlock-controls').click(async event => { + console.log("CONTROLS", this.options.hideControls) this.options.hideControls = !this.options.hideControls; this.render(true); }); @@ -560,7 +569,7 @@ export class RdDActorSheet extends ActorSheet { async _onSplitItem(item, split) { if (split >= 1 && split < Misc.data(item).data.quantite) { await item.diminuerQuantite(split); - const itemData = duplicate( Misc.data(item)); + const itemData = duplicate(Misc.data(item)); itemData.data.quantite = split; await this.actor.createEmbeddedDocuments('Item', [itemData]) } diff --git a/module/actor.js b/module/actor.js index 33381112..14654f01 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3117,11 +3117,9 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - rollArme(compName, armeName = undefined) { - let arme = armeName ? this.data.items.find(it => Misc.data(it).name == armeName && RdDItemArme.isArme(it)) : undefined; - let competence = Misc.data(this.getCompetence(compName)); - - if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) { + rollArme(arme) { + let competence = Misc.data(this.getCompetence(arme.data.competence)); + if (arme || (competence.type == 'competencecreature' && competence.data.iscombat)) { RdDCombat.createUsingTarget(this)?.attaque(competence, arme); } else { this.rollCompetence(competence.name); diff --git a/module/item-arme.js b/module/item-arme.js index 4eed2dca..36f5115c 100644 --- a/module/item-arme.js +++ b/module/item-arme.js @@ -189,6 +189,6 @@ export class RdDItemArme extends Item { if (actorData) { mergeObject(mainsNues.data, actorData, { overwrite: false }); } - return mainsNues + return mainsNues; } } diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 34ca5ec0..7702e184 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -748,7 +748,7 @@ export class RdDCombat { surpriseDefenseur: this.defender.getSurprise(true), essais: {} }; - + if (this.attacker.isCreature()) { RdDItemCompetenceCreature.setRollDataCreature(rollData); } diff --git a/module/rdd-hotbar-drop.js b/module/rdd-hotbar-drop.js index a3efd6b6..2f4e6343 100644 --- a/module/rdd-hotbar-drop.js +++ b/module/rdd-hotbar-drop.js @@ -1,3 +1,4 @@ +import { Misc } from "./misc.js"; export class RdDHotbar { @@ -67,15 +68,14 @@ export class RdDHotbar { let actor; if (speaker.token) actor = game.actors.tokens[speaker.token]; if (!actor) actor = game.actors.get(speaker.actor); - let item = actor ? actor.items.find(i => i.name === itemName && i.type == itemType) : null; - if (!item) return ui.notifications.warn(`Impossible de trouver l'objet de cette macro`); - item = item.data; + let item = Misc.data(actor?.items.find(it => it.name === itemName && it.type == itemType)); + if (!item) return ui.notifications.warn(`Impossible de trouver l'objet de cette macro`); // Trigger the item roll switch (item.type) { case "arme": - return actor.rollArme(item.data.competence, itemName); + return actor.rollArme(item); case "competence": return actor.rollCompetence( itemName ); } diff --git a/module/rdd-token-hud.js b/module/rdd-token-hud.js index d748964f..a754512f 100644 --- a/module/rdd-token-hud.js +++ b/module/rdd-token-hud.js @@ -53,8 +53,7 @@ export class RdDTokenHud { await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData, (event) => { let armeIndex = event.currentTarget.attributes['data-arme-id'].value; - let arme = armesList[armeIndex]; - actor.rollArme(arme.data.competence, arme.name); + actor.rollArme(armesList[armeIndex]); }); }