#87 : Bouton de +1/-1 pour l'init, via menu ou HUD

This commit is contained in:
sladecraven 2021-02-04 13:30:54 +01:00
parent 4bc47f0c5e
commit b2dab45646
4 changed files with 51 additions and 13 deletions

View File

@ -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;
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

View File

@ -756,16 +756,41 @@ 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: '<i class="far fa-question-circle"></i>',
callback: target => {
for (let i =0; i<options.length; i++) {
let option = options[i];
if ( option.name == 'COMBAT.CombatantReroll') { // Replace !
option.name = "Sélectionner l'initiative...";
option.condition = true;
option.icon = '<i class="far fa-question-circle"></i>';
option.callback = target => {
RdDUtility.displayInitiativeMenu(html, target.data('combatant-id'));
}
}
}
options.push( {
name: "Incrémenter initiative",
condition: true,
icon: '<i class="fas fa-plus"></i>',
callback: target => {
RdDUtility.incDecInit(target.data('combatant-id'), +0.01);
}
} );
options.push( {
name: "Décrémenter initiative",
condition: true,
icon: '<i class="fas fa-minus"></i>',
callback: target => {
RdDUtility.incDecInit(target.data('combatant-id'), -0.01);
}
} );
}

View File

@ -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",

View File

@ -2,9 +2,14 @@
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
<div class="rdd-hud-list tokenhudext right">
{{#each armes as |arme key|}}
<div class="control-icon tokenhudicon rdd-hud-menu" data-combatant-id="{{../combatant._id}}" data-arme-id="{{arme.index}}"title="{{arme.name}}">
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{arme.command}}" data-combatant-id="{{../combatant._id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}">
<label>I:{{arme.name}} {{arme.data.mainInfo}}</label>
</div>
{{/each}}
{{#each commandes as |commande key|}}
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{commande.command}}" data-combatant-id="{{../combatant._id}}" data-arme-id="{{commande.index}}" title="{{commande.name}}">
<label>I:{{commande.name}}</label>
</div>
{{/each}}
</div>
</div>