From 5f3c6781950919d0d6f4bf929265e0732fadc951 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 9 Feb 2025 22:28:40 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Fix:=20jet=20de=20caract=C3=A9ristique/diff?= =?UTF-8?q?icult=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les jets avec difficulté ne fonctionnaient plus à cause des armes à 1 main / à 2 mains --- module/apps/textroll/text-roll-carac-competence.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/apps/textroll/text-roll-carac-competence.js b/module/apps/textroll/text-roll-carac-competence.js index aba13fa1..4fe0d8e8 100644 --- a/module/apps/textroll/text-roll-carac-competence.js +++ b/module/apps/textroll/text-roll-carac-competence.js @@ -5,7 +5,7 @@ import { RdDUtility } from "../../rdd-utility.js"; import { TextRollManager } from "./text-roll-formatter.js"; const REGECP_CARAC = "(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)" -const REGEXP_COMP = "(\\/(?[A-Za-z0-9À-ÖØ-öø-ÿ -]+))?" +const REGEXP_COMP = "(\\/(?[A-Za-zÀ-ÖØ-öø-ÿ ]+([1-2]?[A-Za-zÀ-ÖØ-öø-ÿ ]+)?))?" const REGEXP_DIFF = "(/(?[\\+\\-]?\\d+(d\\d+)?))?" const REGEXP_ROLL_CARAC_COMP = REGECP_CARAC + REGEXP_COMP + REGEXP_DIFF const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu') From df76c4bd78f536d6feee3bba1c445d1a59c203d5 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 10 Feb 2025 01:13:23 +0100 Subject: [PATCH 2/3] Corrections automatisations combat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Visiblement des changements sur les callbacks n'avaient pas été finalisés --- module/actor.js | 13 ++--- module/actor/base-actor-reve.js | 11 ++-- module/actor/base-actor.js | 2 +- module/rdd-combat.js | 94 +++++++++++++++++---------------- module/rdd-resolution-table.js | 1 - 5 files changed, 59 insertions(+), 62 deletions(-) diff --git a/module/actor.js b/module/actor.js index 641766d5..e4cc209c 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2643,12 +2643,13 @@ export class RdDActor extends RdDBaseActorSang { } /* -------------------------------------------- */ - async incDecItemUse(itemId, inc = 1) { - const currentItemUse = this.getFlag(SYSTEM_RDD, 'itemUse'); - let itemUse = currentItemUse ? foundry.utils.duplicate(currentItemUse) : {}; - itemUse[itemId] = (itemUse[itemId] ?? 0) + inc; - await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse); - console.log("ITEM USE INC", inc, itemUse); + async incDecItemUse(itemId, shouldIncrease = true) { + if (shouldIncrease) { + const currentItemUse = this.getFlag(SYSTEM_RDD, 'itemUse'); + let itemUse = currentItemUse ? foundry.utils.duplicate(currentItemUse) : {}; + itemUse[itemId] = (itemUse[itemId] ?? 0) + 1; + await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse); + } } /* -------------------------------------------- */ diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index 8daa183f..6004f901 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -277,14 +277,9 @@ export class RdDBaseActorReve extends RdDBaseActor { return dialog } - createEmptyCallback() { - return { - condition: r => false, - action: r => { } - }; - } - createCallbackExperience() { return this.createEmptyCallback(); } - createCallbackAppelAuMoral() { return this.createEmptyCallback(); } + createCallbackExperience() { return { action: r => { } } } + createCallbackAppelAuMoral() { return { action: r => { } } } + async _onCloseRollDialog(html) { } async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) { diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index 0ca304d4..9fc3c76f 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -747,7 +747,7 @@ export class RdDBaseActor extends Actor { async jetDeMoral() { this.actionImpossible("jet de moral") } async resetItemUse() { } - async incDecItemUse(itemId, inc = 1) { } + async incDecItemUse(itemId, shouldIncrease = true) { } getItemUse(itemId) { return 0; } async finDeRound(options = { terminer: false }) { } diff --git a/module/rdd-combat.js b/module/rdd-combat.js index a5193169..3dbc59cb 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -743,23 +743,13 @@ export class RdDCombat { this.attacker.createCallbackExperience(), this.attacker.createCallbackAppelAuMoral(), { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, - { action: r => this._increaseItemUse(r, arme) }, - { action: r => this._onAttaqueNormale(r) }, - { action: r => this._onAttaqueParticuliere(r) }, - { action: r => this._onAttaqueEchec(r) }, - { action: r => this._onAttaqueEchecTotal(r) }, + { action: async r => await this.attacker.incDecItemUse(arme._id, arme && !RdDCombat.isParticuliere(r)) }, + { action: r => this._onAttaque(r) }, ] }); dialog.render(true); } - _increaseItemUse(rollData, arme) { - if (!arme || RdDCombat.isParticuliere(rollData)) { - return - } - this.attacker.incDecItemUse(arme._id) - } - /* -------------------------------------------- */ _prepareAttaque(competence, arme) { let rollData = { @@ -790,11 +780,23 @@ export class RdDCombat { return rollData; } + async _onAttaque(attackerRoll) { + if (RdDCombat.isParticuliere(attackerRoll)) { + return await this._onAttaqueParticuliere(attackerRoll) + } + if (RdDCombat.isReussite(attackerRoll)) { + return await this._onAttaqueNormale(attackerRoll) + } + // if (RdDCombat.isParticuliere(attackerRoll) && attackerRoll.particuliere == undefined) { + // return + // } + if (RdDCombat.isEchecTotal(attackerRoll)) { + return await this._onAttaqueEchecTotal(attackerRoll) + } + return await this._onAttaqueEchec(attackerRoll) + } /* -------------------------------------------- */ async _onAttaqueParticuliere(rollData) { - if (!RdDCombat.isParticuliere(rollData)) { - return - } const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0; // force toujours, sauf empoignade // finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum @@ -832,12 +834,6 @@ export class RdDCombat { /* -------------------------------------------- */ async _onAttaqueNormale(attackerRoll) { - if (!RdDCombat.isReussite(attackerRoll)) { - return - } - if (RdDCombat.isParticuliere(attackerRoll) && attackerRoll.particuliere == undefined) { - return - } console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite()); @@ -954,9 +950,6 @@ export class RdDCombat { /* -------------------------------------------- */ async _onAttaqueEchecTotal(attackerRoll) { - if (!RdDCombat.isEchecTotal(attackerRoll)) { - return - } const choixEchecTotal = await ChatMessage.create({ whisper: ChatUtility.getOwners(this.attacker), content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', { @@ -983,22 +976,16 @@ export class RdDCombat { } /* -------------------------------------------- */ - async _onAttaqueEchec(rollData) { - if (!RdDCombat.isEchec(rollData)) { - return - } - console.log("RdDCombat.onAttaqueEchec >>>", rollData); - await RdDRollResult.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.hbs'); - + async _onAttaqueEchec(attackerRoll) { + console.log("RdDCombat.onAttaqueEchec >>>", attackerRoll); + await RdDRollResult.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.hbs'); } /* -------------------------------------------- */ async choixParticuliere(rollData, choix) { console.log("RdDCombat.choixParticuliere >>>", rollData, choix); - if (choix != "rapidite") { - this.attacker.incDecItemUse(rollData.arme.id); - } + await this.attacker.incDecItemUse(rollData.arme.id, choix != "rapidite") this.removeChatMessageActionsPasseArme(rollData.passeArme); rollData.particuliere = choix; @@ -1026,10 +1013,8 @@ export class RdDCombat { this.defender.createCallbackExperience(), this.defender.createCallbackAppelAuMoral(), { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, - { condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(armeParadeId) }, - { condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) }, - { condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) }, - { condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) }, + { action: async r => await this.defender.incDecItemUse(armeParadeId, !RdDCombat.isParticuliere(r)) }, + { action: r => this._onParade(r) }, ] }); dialog.render(true); @@ -1060,8 +1045,19 @@ export class RdDCombat { return defenderRoll; } + + async _onParade(defenderRoll) { + if (RdDCombat.isParticuliere(defenderRoll)) { + return await this._onParadeParticuliere(defenderRoll) + } + if (RdDCombat.isReussite(defenderRoll)) { + return await this._onParadeNormale(defenderRoll) + } + await this._onParadeEchec(defenderRoll) + } + /* -------------------------------------------- */ - _onParadeParticuliere(defenderRoll) { + async _onParadeParticuliere(defenderRoll) { console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll); if (!defenderRoll.attackerRoll.isPart) { // TODO: attaquant doit jouer résistance et peut être désarmé p132 @@ -1070,7 +1066,6 @@ export class RdDCombat { this.defender) } } - /* -------------------------------------------- */ async _onParadeNormale(defenderRoll) { console.log("RdDCombat._onParadeNormale >>>", defenderRoll); @@ -1109,11 +1104,9 @@ export class RdDCombat { callbacks: [ this.defender.createCallbackExperience(), this.defender.createCallbackAppelAuMoral(), - { condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(esquive._id) }, + { action: async r => await this.defender.incDecItemUse(esquive._id, !RdDCombat.isParticuliere(r)) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, - { condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) }, - { condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) }, - { condition: RdDCombat.isEchec, action: r => this._onEsquiveEchec(r) }, + { action: r => this._onEsquive(r) }, ] }); dialog.render(true); @@ -1141,9 +1134,18 @@ export class RdDCombat { return rollData; } + async _onEsquive(defenderRoll) { + if (RdDCombat.isParticuliere(defenderRoll)) { + return await this._onEsquiveParticuliere(defenderRoll) + } + if (RdDCombat.isReussite(defenderRoll)) { + return await this._onEsquiveNormale(defenderRoll) + } + return await this._onEsquiveEchec(defenderRoll) + } /* -------------------------------------------- */ - _onEsquiveParticuliere(rollData) { - console.log("RdDCombat._onEsquiveParticuliere >>>", rollData); + async _onEsquiveParticuliere(defenderRoll) { + console.log("RdDCombat._onEsquiveParticuliere >>>", defenderRoll); ChatUtility.createChatWithRollMode( { content: "Vous pouvez esquiver une deuxième fois!" }, this.defender); diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index c78b42ef..9942d5d1 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -1,4 +1,3 @@ -import { ChatUtility } from "./chat-utility.js"; import { Misc } from "./misc.js"; import { RdDDice } from "./rdd-dice.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; From 54785f0c3a01a1904895ba0499b8b2469be19c5d Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 10 Feb 2025 01:16:12 +0100 Subject: [PATCH 3/3] Version 12.0.42 --- changelog.md | 4 ++++ system.json | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 52c1b561..a9fe7565 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # 12.0 +## 12.0.42 - Les errements d'Astrobazzarh +- Correction de différentes automatisations de combat incorrectes +- Correction des jets `@roll[vue/-2]` qui tentaient de chercher une compétence -2 (à cause des armes à 1/2 mains) + ## 12.0.41 - La loupe d'Astrobazzarh - On peut de nouveau effectuer des tirages cachés - Le stress transformé est bien diminué lorsqu'on met le stress dans une compétence diff --git a/system.json b/system.json index 0e911d57..ac2681a8 100644 --- a/system.json +++ b/system.json @@ -1,9 +1,9 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "12.0.38", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/releases/download/12.0.38/rddsystem.zip", - "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/releases/download/12.0.38/system.json", + "version": "12.0.42", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/releases/download/12.0.42/rddsystem.zip", + "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/releases/download/12.0.42/system.json", "changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md", "compatibility": { "minimum": "11",