From b2dab4564655df3a0b4240c8beb9d4206f1e836a Mon Sep 17 00:00:00 2001 From: sladecraven Date: Thu, 4 Feb 2021 13:30:54 +0100 Subject: [PATCH] #87 : Bouton de +1/-1 pour l'init, via menu ou HUD --- module/rdd-token-hud.js | 16 ++++++++++---- module/rdd-utility.js | 39 ++++++++++++++++++++++++++++------- system.json | 2 +- templates/hud-actor-init.html | 7 ++++++- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/module/rdd-token-hud.js b/module/rdd-token-hud.js index 501f4928..0f9abcb0 100644 --- a/module/rdd-token-hud.js +++ b/module/rdd-token-hud.js @@ -27,15 +27,23 @@ export class RdDTokenHud { app.hasExtension = true; let armesList = RdDUtility.buildListeActionsCombat(combatant) ; - const hudData = { combatant: combatant, armes: armesList }; + const hudData = { combatant: combatant, armes: armesList, + commandes: [{ name: 'Initiative +1', command: 'inc', value: 0.01}, { name: 'Initiative -1',command: 'dec', value: -0.01}] }; // initiative await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData, (event) => { - let armeIndex = event.currentTarget.attributes['data-arme-id'].value; + let initCommand = event.currentTarget.attributes['data-command'].value; let combatantId = event.currentTarget.attributes['data-combatant-id'].value; - let arme = armesList[armeIndex]; - RdDUtility.rollInitiativeCompetence(combatantId, arme); + if ( !initCommand ) { + let armeIndex = event.currentTarget.attributes['data-arme-id'].value; + let arme = armesList[armeIndex]; + RdDUtility.rollInitiativeCompetence(combatantId, arme); + } else if (initCommand == 'inc') { + RdDUtility.incDecInit( combatantId, 0.01 ); + } else if ( initCommand == 'dec') { + RdDUtility.incDecInit( combatantId, -0.01 ); + } }); // combat diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 5062a405..868ee8d4 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -756,17 +756,42 @@ export class RdDUtility { } } + /* -------------------------------------------- */ + static incDecInit(combatantId, incDecValue ) { + const combatant = game.combat.getCombatant(combatantId); + let initValue = combatant.initiative + incDecValue; + game.combat.setInitiative( combatantId, initValue ); + } + /* -------------------------------------------- */ static pushInitiativeOptions(html, options) { - options.push( - { - name: "Sélectionner l'initiative...", - condition: true, - icon: '', - callback: target => { + for (let i =0; i { RdDUtility.displayInitiativeMenu(html, target.data('combatant-id')); } - }); + } + } + options.push( { + name: "Incrémenter initiative", + condition: true, + icon: '', + callback: target => { + RdDUtility.incDecInit(target.data('combatant-id'), +0.01); + } + } ); + options.push( { + name: "Décrémenter initiative", + condition: true, + icon: '', + callback: target => { + RdDUtility.incDecInit(target.data('combatant-id'), -0.01); + } + } ); } /* -------------------------------------------- */ diff --git a/system.json b/system.json index 3f500662..43964d90 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.3.12", + "version": "1.3.13", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", diff --git a/templates/hud-actor-init.html b/templates/hud-actor-init.html index 22b73058..9865510a 100644 --- a/templates/hud-actor-init.html +++ b/templates/hud-actor-init.html @@ -2,9 +2,14 @@
{{#each armes as |arme key|}} -
+
{{/each}} + {{#each commandes as |commande key|}} +
+ +
+ {{/each}}