From 68152e6bb21d136f0931736299ece464aa2c3c5c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 19:58:19 +0100 Subject: [PATCH 1/7] fix suppression defense sur passe d'armes --- module/rdd-combat.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index c4183b1b..01edeea0 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -126,7 +126,7 @@ export class RdDCombat { /* -------------------------------------------- */ static _deleteDefense(passeArme) { - delete game.system.rdd.combatStore.defenses; + delete game.system.rdd.combatStore.defenses[passeArme]; } /* -------------------------------------------- */ @@ -647,7 +647,7 @@ export class RdDCombat { this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true }); - this._storeDefense(defenderRoll); + RdDCombat._storeDefense(defenderRoll); } /* -------------------------------------------- */ @@ -719,7 +719,7 @@ export class RdDCombat { this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true }) - this._storeDefense(defenderRoll); + RdDCombat._storeDefense(defenderRoll); } /* -------------------------------------------- */ From c23065119e45c7a71ab2283245536467d7a6e88d Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 22:31:32 +0100 Subject: [PATCH 2/7] Fix messages passe d'arme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - l'attaquant ne peut plus lancer les dés du défenseur (sauf GM) - ajout du nom de l'attaquant au message de défense - nettoyage des messages de la passe d'arme uniqument par le GM pour éviter suppression par le joueur --- module/rdd-combat.js | 123 ++++++++++++++++------------ templates/chat-demande-defense.html | 8 +- 2 files changed, 76 insertions(+), 55 deletions(-) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 01edeea0..d4cd0726 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -107,27 +107,27 @@ export class RdDCombat { /* -------------------------------------------- */ static _getAttaque(attackerId) { return game.system.rdd.combatStore.attaques[attackerId]; - } - + } + /* -------------------------------------------- */ static _deleteAttaque(attackerId) { delete game.system.rdd.combatStore.attaques[attackerId]; - } + } /* -------------------------------------------- */ static _storeDefense(defenderRoll) { game.system.rdd.combatStore.defenses[defenderRoll.passeArme] = duplicate(defenderRoll); - } + } /* -------------------------------------------- */ static _getDefense(passeArme) { return game.system.rdd.combatStore.defenses[passeArme]; - } - + } + /* -------------------------------------------- */ static _deleteDefense(passeArme) { delete game.system.rdd.combatStore.defenses[passeArme]; - } + } /* -------------------------------------------- */ static create(attacker, defender, defenderTokenId, target = undefined) { @@ -135,15 +135,11 @@ export class RdDCombat { } /* -------------------------------------------- */ - static createForEvent(event) { - let attackerId = event.currentTarget.attributes['data-attackerId'].value; - let attacker = game.actors.get(attackerId); - - const dataDefenderTokenId = event.currentTarget.attributes['data-defenderTokenId']; - if (dataDefenderTokenId) { - const defenderTokenId = dataDefenderTokenId.value; - let defenderToken = canvas.tokens.get(defenderTokenId); - let defender = defenderToken.actor; + static createForAttackerAndDefender(attackerId, defenderTokenId) { + const attacker = game.actors.get(attackerId); + if (defenderTokenId) { + const defenderToken = canvas.tokens.get(defenderTokenId); + const defender = defenderToken.actor; return RdDCombat.create(attacker, defender, defenderTokenId); } @@ -166,17 +162,19 @@ export class RdDCombat { } /* -------------------------------------------- */ - static onMsgDefense(msgData) { - let defenderToken = canvas.tokens.get(msgData.defenderTokenId); + static onMsgDefense(msg) { + let defenderToken = canvas.tokens.get(msg.defenderTokenId); if (defenderToken) { if (!game.user.isGM && !game.user.character) { // vérification / sanity check ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer."); return; } - if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character.id == defenderToken.actor.data._id))) { - const defenderRoll = msgData.defenderRoll; - RdDCombat._storeAttaque(msgData.attackerId, defenderRoll.attackerRoll); + if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character._id == defenderToken.actor.data._id))) { + const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); + const defenderRoll = msg.defenderRoll; + RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll); RdDCombat._storeDefense(defenderRoll); + rddCombat._chatMessageDefense(msg.paramChatDefense); } } } @@ -202,8 +200,12 @@ export class RdDCombat { '#echec-total-attaque', ]) { html.on("click", button, event => { + const rddCombat = RdDCombat.createForAttackerAndDefender( + event.currentTarget.attributes['data-attackerId']?.value, + event.currentTarget.attributes['data-defenderTokenId']?.value); + + rddCombat.onEvent(button, event); event.preventDefault(); - RdDCombat.createForEvent(event).onEvent(button, event); }); } html.on("click", '#chat-jet-vie', event => { @@ -308,7 +310,7 @@ export class RdDCombat { /* -------------------------------------------- */ removeChatMessageActionsPasseArme(passeArme) { - if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) { + if (game.user.isGM && game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) { ChatUtility.removeMyChatMessageContaining(`
`); } } @@ -413,7 +415,8 @@ export class RdDCombat { attackerId: this.attackerId, defenderTokenId: this.defenderTokenId, isFinesse: isMeleeDiffNegative, - isRapide: isMeleeDiffNegative && rollData.arme.data.rapide + isRapide: isMeleeDiffNegative && rollData.arme.data.rapide, + passeArme: rollData.passeArme }) }); } @@ -423,9 +426,10 @@ export class RdDCombat { console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); - + let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} } // Save rollData for defender RdDCombat._storeAttaque(this.attackerId, attackerRoll); + RdDCombat._storeDefense(defenderRoll) attackerRoll.show = { cible: this.target ? this.defender.data.name : 'la cible', @@ -438,57 +442,69 @@ export class RdDCombat { } if (this.target) { - await this._sendMessageDefense(attackerRoll); + await this._sendMessageDefense(attackerRoll, defenderRoll); } } /* -------------------------------------------- */ - async _sendMessageDefense(attackerRoll, defenderRoll = undefined, essaisPrecedents = undefined) { + async _sendMessageDefense(attackerRoll, defenderRoll, essaisPrecedents = undefined) { console.log("RdDCombat._sendMessageDefense", attackerRoll, defenderRoll, essaisPrecedents, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); if (essaisPrecedents) { mergeObject(attackerRoll.essais, essaisPrecedents, { overwrite: true }); } - const paramDemandeDefense = { + const paramChatDefense = { passeArme: attackerRoll.passeArme, essais: attackerRoll.essais, defender: this.defender, + attacker: this.attacker, attackerId: this.attackerId, defenderTokenId: this.defenderTokenId, mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"), armes: this._filterArmesParade(this.defender.data.items, attackerRoll.competence, attackerRoll.arme), diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0, attaqueParticuliere: attackerRoll.particuliere, - dmg: attackerRoll.dmg + attaqueCategorie: attackerRoll.competence.data.categorie, + attaqueArme: attackerRoll.arme, + dmg: attackerRoll.dmg, }; - RdDCombat._sendRollMessage(this.attacker, this.defender, this.defenderTokenId, - defenderRoll ?? { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} }, - essaisPrecedents != undefined); - - let chatMessage = { - alias: this.attacker.name, - whisper: ChatUtility.getWhisperRecipientsAndGMs(this.defender.name), - content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', paramDemandeDefense), - }; - ChatMessage.create(chatMessage); + const selfMessage = essaisPrecedents != undefined; + if (!selfMessage && (!game.user.isGM || this.defender.hasPlayerOwner)) { + this._socketSendMessageDefense(paramChatDefense, defenderRoll); + } + else { + await this._chatMessageDefense(paramChatDefense); + } } /* -------------------------------------------- */ - static _sendRollMessage(sender, recipient, defenderTokenId, defenderRoll, selfMessage) { - // envoyer le message au destinataire - if (!selfMessage || !game.user.isGM || recipient.hasPlayerOwner) { - let data = { - attackerId: sender?.data._id, - defenderId: recipient?.data._id, - defenderTokenId: defenderTokenId, - defenderRoll: duplicate(defenderRoll), - rollMode: true - }; - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_defense", data: data }); - } + async _chatMessageDefense(paramDemandeDefense) { + ChatMessage.create({ + // message privé: du défenseur à lui même (et aux GMs) + speaker: ChatMessage.getSpeaker(this.defender, canvas.tokens.get(this.defenderTokenId)), + alias: this.attacker.name, + whisper: ChatUtility.getWhisperRecipientsAndGMs(this.defender.name), + content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', paramDemandeDefense), + }); } + + /* -------------------------------------------- */ + _socketSendMessageDefense(paramChatDefense, defenderRoll) { + // envoyer le message au destinataire + game.socket.emit("system.foundryvtt-reve-de-dragon", { + msg: "msg_defense", data: { + attackerId: this.attacker?.data._id, + defenderId: this.defender?.data._id, + defenderTokenId: this.defenderTokenId, + defenderRoll: duplicate(defenderRoll), + paramChatDefense: paramChatDefense, + rollMode: true + } + }); + } + /* -------------------------------------------- */ _filterArmesParade(items, competence) { items = items.filter(item => (item.type == 'arme' && item.data.equipe) || (item.type == 'competencecreature' && item.data.isparade)); @@ -809,6 +825,10 @@ export class RdDCombat { console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId); let defenderRoll = RdDCombat._getDefense(attackerRoll.passeArme); + if (!defenderRoll) { + ui.notifications.warn("Cette passe d'arme est déjà terminée!") + return; + } if (defenderRoll?.rolled && RdDCombat.isEchecTotal(defenderRoll)) { this._onEchecTotal(defenderRoll); } @@ -831,6 +851,7 @@ export class RdDCombat { }); } RdDCombat._deleteDefense(attackerRoll.passeArme); + this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); } /* -------------------------------------------- */ diff --git a/templates/chat-demande-defense.html b/templates/chat-demande-defense.html index 5ffead54..8b9b1ade 100644 --- a/templates/chat-demande-defense.html +++ b/templates/chat-demande-defense.html @@ -5,13 +5,13 @@ {{defender.name}} doit : {{else}} {{defender.name}} doit se défendre - {{~#if (eq surprise 'demi')}} avec une significative {{/if~}} - {{~#if attaqueParticuliere}} contre une particulière en + {{~#if (eq surprise 'demi')}} avec une significative {{/if}} d'une attaque + {{~#if attaqueParticuliere}} particulière en {{~#if (eq attaqueParticuliere 'finesse')}} finesse {{else if (eq attaqueParticuliere 'force')}} force - {{else}} rapidité + {{else if (eq attaqueParticuliere 'rapidite')}} rapidité {{/if~}} - {{/if~}} : + {{/if}} de {{attacker.name}} ({{attaqueArme.name}}): {{/if}} From 3cfeeadbb66185fa28281debf7aae74361807587 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 22:32:08 +0100 Subject: [PATCH 3/7] Seuls les personnages sont saouls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pas d'éthylisme pour les créatures --- module/actor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/actor.js b/module/actor.js index 78aa7024..5be84288 100644 --- a/module/actor.js +++ b/module/actor.js @@ -391,7 +391,9 @@ export class RdDActor extends Actor { } await this.update({ "data.blessures": blessures }); } - await this.setEthylisme(1); + if (this.isPersonnage()) { + await this.setEthylisme(1); + } await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); From 0e5495c6c4164c3e4a1a9e704f9f206e7d18c0a9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 22:50:02 +0100 Subject: [PATCH 4/7] =?UTF-8?q?Fix=20d=C3=A9t=C3=A9rioration=20d'armure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 55 ++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/module/actor.js b/module/actor.js index 5be84288..78e19e36 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2177,36 +2177,18 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ computeArmure(attackerRoll) { - let dmg = attackerRoll.dmg.dmgArme + attackerRoll.dmg.dmgActor; + let dmg = (attackerRoll.dmg.dmgArme ??0) + (attackerRoll.dmg.dmgActor ?? 0); let arme = attackerRoll.arme; - // TODO: arc ignore armure let protection = 0; - for (const item of this.data.items) { - if (item.type == "armure" && item.data.equipe) { - let update = duplicate(item); - protection += new Roll(update.data.protection.toString()).roll().total; - update.data.deterioration = Misc.toInt(update.data.deterioration) + dmg; - dmg = 0; // Reset it - if (update.data.deterioration >= 10) { - update.data.deterioration = 0; - let res = /\d+/.exec(update.data.protection); - if (res) - update.data.protection = "1d" + update.data.protection; - // if ( update.data.protection.toString().length == 1 ) - // update.data.protection = "1d"+update.data.protection; - else if (res = /(\d+d\d+)(\-\d+)?/.exec(update.data.protection)) { - let malus = Misc.toInt(res[2]) - 1; - update.data.protection = res[1] + malus; - } - else { - ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`) - } - ChatMessage.create({ content: "Détérioration d'armure: " + update.data.protection }); - } - this.updateEmbeddedEntity("OwnedItem", update); + const armures = this.data.items.filter(it => it.type == "armure" && it.data.equipe); + for (const item of armures) { + protection += new Roll(item.data.protection.toString()).roll().total; + if (dmg > 0) { + this._deteriorerArmure(item, dmg); + dmg = 0; } } - // TODO: max armure (chutes) + // TODO: max armure sur chutes... const penetration = arme ? Misc.toInt(arme.data.penetration) : 0; protection = Math.max(protection - penetration, 0); protection += this.getProtectionNaturelle(); @@ -2214,6 +2196,27 @@ export class RdDActor extends Actor { return protection; } + _deteriorerArmure(item, dmg) { + let update = duplicate(item); + update.data.deterioration = (update.data.deterioration ?? 0) + dmg; + if (update.data.deterioration >= 10) { + update.data.deterioration = 0; + let res = /\d+/.exec(update.data.protection); + if (!res) { + update.data.protection = "1d" + update.data.protection; + } + else if (res = /(\d+d\d+)(\-\d+)?/.exec(update.data.protection)) { + let malus = Misc.toInt(res[2]) - 1; + update.data.protection = res[1] + malus; + } + else { + ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`); + } + ChatMessage.create({ content: "Votre armure s'est détériorée, elle protège maintenant de " + update.data.protection }); + } + this.updateEmbeddedEntity("OwnedItem", update); + } + /* -------------------------------------------- */ async encaisser() { let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }; From 4efd8cdd0be784bdf32357fc7af527e258602392 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 22:51:09 +0100 Subject: [PATCH 5/7] Fix set status-effects seulement pour le GM --- module/status-effects.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/module/status-effects.js b/module/status-effects.js index b8e6f572..3e509e47 100644 --- a/module/status-effects.js +++ b/module/status-effects.js @@ -30,9 +30,8 @@ export class StatusEffects { restricted: true }); CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects); - + StatusEffects._setUseStatusEffects(StatusEffects._getUseStatusEffects()); - console.log('statusEffects', CONFIG.statusEffects); } @@ -65,7 +64,9 @@ export class StatusEffects { } static _setUseStatusEffects(useStatusEffects) { - game.settings.set("foundryvtt-reve-de-dragon", "use-status-effects", StatusEffects._toSetting(useStatusEffects)); + if (game.user.isGM) { + game.settings.set("foundryvtt-reve-de-dragon", "use-status-effects", StatusEffects._toSetting(useStatusEffects)); + } for (let effect of CONFIG.RDD.allEffects) { effect.active = effect.rdd || useStatusEffects.has(effect.id); From 807e58e36a56ca8602c60aca9f9f2fb36b19dfec Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 23:01:14 +0100 Subject: [PATCH 6/7] =?UTF-8?q?Fix=20pertes=20des=20entit=C3=A9s=20de=20ca?= =?UTF-8?q?uchemar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/module/actor.js b/module/actor.js index 78e19e36..5dff7740 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1151,7 +1151,7 @@ export class RdDActor extends Actor { const sante = duplicate(this.data.data.sante); let compteur = sante[name]; if (!compteur) { - return; + return ; } let result = { sonne: false, @@ -2236,7 +2236,9 @@ export class RdDActor extends Actor { let encaissement = this.jetEncaissement(rollData); this.ajouterBlessure(encaissement); // Will upate the result table - const perteVie = await this.santeIncDec("vie", - encaissement.vie); + const perteVie = this.isEntiteCauchemar() + ? { newValue: 0} + : await this.santeIncDec("vie", - encaissement.vie); const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, (encaissement.critiques > 0)); this.computeEtatGeneral(); @@ -2250,7 +2252,7 @@ export class RdDActor extends Actor { encaissement.sonne = perteEndurance.sonne; encaissement.jetEndurance = perteEndurance.jetEndurance; encaissement.endurance = santeOrig.endurance.value - perteEndurance.newValue; - encaissement.vie = santeOrig.vie.value - perteVie.newValue; + encaissement.vie = this.isEntiteCauchemar() ? 0 : (santeOrig.vie.value - perteVie.newValue); ChatUtility.createChatWithRollMode(this.name, { roll: encaissement.roll, From 7db9834b9a1672f0149500408ffabf53583702e4 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 19 Jan 2021 23:39:35 +0100 Subject: [PATCH 7/7] =?UTF-8?q?Fix=20double=20effet=20cr=C3=A9atures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor-creature-sheet.js | 124 ++++++--------------------- module/actor-entite-sheet.js | 4 +- module/actor-sheet.js | 3 +- module/actor.js | 20 ++--- templates/actor-creature-sheet.html | 2 +- templates/actor-entite-sheet.html | 2 +- templates/actor-humanoide-sheet.html | 2 +- templates/actor-sheet.html | 2 +- 8 files changed, 38 insertions(+), 121 deletions(-) diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index 823c6495..b9a820d7 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -8,18 +8,18 @@ import { HtmlUtility } from "./html-utility.js"; import { RdDUtility } from "./rdd-utility.js"; import { RdDActorSheet } from "./actor-sheet.js"; -/* -------------------------------------------- */ +/* -------------------------------------------- */ export class RdDActorCreatureSheet extends RdDActorSheet { /** @override */ - static get defaultOptions() { - return mergeObject(super.defaultOptions, { - classes: ["rdd", "sheet", "actor"], - template: "systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html", + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + classes: ["rdd", "sheet", "actor"], + template: "systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html", width: 640, height: 720, - tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}], - dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}] + tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }], + dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }] }); } @@ -41,30 +41,30 @@ export class RdDActorCreatureSheet extends RdDActorSheet { // Compute current carac sum let sum = 0; - Object.values(data.data.carac).forEach(carac => { if (!carac.derivee) { sum += parseInt(carac.value) } } ); + Object.values(data.data.carac).forEach(carac => { if (!carac.derivee) { sum += parseInt(carac.value) } }); data.data.caracSum = sum; - + data.data.carac.taille.isTaille = true; // To avoid button link; data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures); data.data.isGM = game.user.isGM; data.data.competencecreature = data.itemsByType["competencecreature"]; - + this.actor.computeEncombrementTotalEtMalusArmure(); - RdDUtility.filterItemsPerTypeForSheet(data ); - RdDUtility.buildArbreDeConteneur( this, data ); + RdDUtility.filterItemsPerTypeForSheet(data); + RdDUtility.buildArbreDeConteneur(this, data); data.data.encTotal = this.actor.encTotal; data.data.isGM = game.user.isGM; - console.log("Creature : ", this.objetVersConteneur , data); + console.log("Creature : ", this.objetVersConteneur, data); return data; } /* -------------------------------------------- */ /** @override */ - activateListeners(html) { + activateListeners(html) { super.activateListeners(html); HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); @@ -72,101 +72,25 @@ export class RdDActorCreatureSheet extends RdDActorSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; - // Update Inventory Item - html.find('.item-edit').click(ev => { - const li = $(ev.currentTarget).parents(".item"); - const item = this.actor.getOwnedItem(li.data("itemId")); - item.sheet.render(true); - }); - - // Delete Inventory Item - html.find('.item-delete').click(ev => { - const li = $(ev.currentTarget).parents(".item"); - this.actor.deleteOwnedItem(li.data("itemId")); - li.slideUp(200, () => this.render(false)); - }); - - // Blessure control - html.find('.blessure-control').click(ev => { - const li = $(ev.currentTarget).parents(".item"); - let btype = li.data("blessure-type"); - let index = li.data('blessure-index'); - let active = $(ev.currentTarget).data('blessure-active'); - //console.log(btype, index, active); - this.actor.manageBlessureFromSheet(btype, index, active).then( this.render(true) ); - }); - - // Blessure data - html.find('.blessures-soins').change(ev => { - 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(); - let pcomplets = li.find('input[name=soins_complets]').val(); - let jours = li.find('input[name=jours]').val(); - let loc = li.find('input[name=localisation]').val(); - //console.log(btype, index, psoins, pcomplets, jours, loc); - this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then( this.render(true) ); - }); - - // Roll Carac - html.find('.carac-label a').click((event) => { - let caracName = event.currentTarget.attributes.name.value; - this.actor.rollCarac( caracName.toLowerCase() ); - }); - // On competence change html.find('.creature-carac').change((event) => { - let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.value) ); - } ); + let compName = event.currentTarget.attributes.compname.value; + this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value)); + }); html.find('.creature-niveau').change((event) => { - let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.value) ); - } ); - html.find('.creature-dommages').change((event) => { - let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) ); - } ); - - // Roll Skill - html.find('.competence-label a').click((event) => { - let compName = event.currentTarget.text; - this.actor.rollCompetenceCreature( compName ); + let compName = event.currentTarget.attributes.compname.value; + this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value)); }); - - html.find('#vie-plus').click((event) => { - this.actor.santeIncDec("vie", 1); - this.render(true); - }); - html.find('#vie-moins').click((event) => { - this.actor.santeIncDec("vie", -1); - this.render(true); - }); - html.find('#endurance-plus').click((event) => { - this.actor.santeIncDec("endurance", 1); - this.render(true); - }); - html.find('#endurance-moins').click((event) => { - this.actor.santeIncDec("endurance", -1); - this.render(true); - }); - - html.find('#encaisser-direct').click(ev => { - this.actor.encaisser(); - }); - - html.find('#remise-a-neuf').click(ev => { - if (game.user.isGM) { - this.actor.remiseANeuf(); - } + html.find('.creature-dommages').change((event) => { + let compName = event.currentTarget.attributes.compname.value; + this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value)); }); } - + /* -------------------------------------------- */ /** @override */ - setPosition(options={}) { + setPosition(options = {}) { const position = super.setPosition(options); const sheetBody = this.element.find(".sheet-body"); const bodyHeight = position.height - 192; diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js index ea5a1e23..8e9f3c93 100644 --- a/module/actor-entite-sheet.js +++ b/module/actor-entite-sheet.js @@ -96,7 +96,7 @@ export class RdDActorEntiteSheet extends ActorSheet { // Roll Skill html.find('.competence-label a').click((event) => { let compName = event.currentTarget.text; - this.actor.rollCompetenceCreature( compName ); + this.actor.rollCompetence( compName ); }); html.find('#endurance-plus').click((event) => { @@ -112,7 +112,7 @@ export class RdDActorEntiteSheet extends ActorSheet { this.actor.encaisser(); }); - html.find('#remise-a-neuf').click(ev => { + html.find('.remise-a-neuf').click(ev => { if (game.user.isGM) { this.actor.remiseANeuf(); } diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 293f4f47..33e4f2c3 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -207,9 +207,10 @@ export class RdDActorSheet extends ActorSheet { this.actor.encaisser(); }); - html.find('#remise-a-neuf').click(ev => { + html.find('.remise-a-neuf').click(ev => { if (game.user.isGM) { this.actor.remiseANeuf(); + ev.preventDefault(); } }); html.find('#creer-tache').click(ev => { diff --git a/module/actor.js b/module/actor.js index 5dff7740..1e89f187 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1753,8 +1753,13 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollCompetence(name) { let rollData = { competence: this.getCompetence(name) } - + if (rollData.competence.type == 'competencecreature') { + if (rollData.competence.data.iscombat) { + const arme = RdDItemCompetenceCreature.toArme(competence); + RdDCombat.createUsingTarget(this).attaque(competence, arme); + return; + } // Fake competence pour créature RdDItemCompetenceCreature.setRollDataCreature(rollData); } @@ -2125,19 +2130,6 @@ export class RdDActor extends Actor { this.currentTMR.render(true); } - - /* -------------------------------------------- */ - async rollCompetenceCreature(compName) { - const competence = this.getCompetence(compName); - if (competence.type == 'competencecreature' && competence.data.iscombat) { - const arme = RdDItemCompetenceCreature.toArme(competence); - RdDCombat.createUsingTarget(this).attaque(competence, arme); - } - else { - this.rollCompetence(competence.name); - } - } - /* -------------------------------------------- */ rollArme(compName, armeName = undefined) { let arme = armeName ? this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)) : undefined; diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 12e5a346..1901d9eb 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -10,7 +10,7 @@
Encaisser des dommages - Remise à neuf + Remise à neuf
diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html index 16bc64f3..1f03d5cd 100644 --- a/templates/actor-entite-sheet.html +++ b/templates/actor-entite-sheet.html @@ -10,7 +10,7 @@
Encaisser des dommages - Remise à neuf + Remise à neuf
diff --git a/templates/actor-humanoide-sheet.html b/templates/actor-humanoide-sheet.html index eb441bc3..39126bc7 100644 --- a/templates/actor-humanoide-sheet.html +++ b/templates/actor-humanoide-sheet.html @@ -10,7 +10,7 @@
Encaisser des dommages - Remise à neuf + Remise à neuf
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 5c6c1e6d..c545c781 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -57,7 +57,7 @@
Encaisser des dommages - Remise à neuf + Remise à neuf Dormir une heure Chateau Dormant Montée dans les Terres Médianes !