#87 : Bouton de +1/-1 pour l'init, via menu ou HUD
This commit is contained in:
parent
4bc47f0c5e
commit
b2dab45646
@ -27,15 +27,23 @@ export class RdDTokenHud {
|
|||||||
app.hasExtension = true;
|
app.hasExtension = true;
|
||||||
|
|
||||||
let armesList = RdDUtility.buildListeActionsCombat(combatant) ;
|
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
|
// initiative
|
||||||
await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData,
|
await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData,
|
||||||
(event) => {
|
(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 combatantId = event.currentTarget.attributes['data-combatant-id'].value;
|
||||||
|
if ( !initCommand ) {
|
||||||
|
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
||||||
let arme = armesList[armeIndex];
|
let arme = armesList[armeIndex];
|
||||||
RdDUtility.rollInitiativeCompetence(combatantId, arme);
|
RdDUtility.rollInitiativeCompetence(combatantId, arme);
|
||||||
|
} else if (initCommand == 'inc') {
|
||||||
|
RdDUtility.incDecInit( combatantId, 0.01 );
|
||||||
|
} else if ( initCommand == 'dec') {
|
||||||
|
RdDUtility.incDecInit( combatantId, -0.01 );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// combat
|
// combat
|
||||||
|
@ -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) {
|
static pushInitiativeOptions(html, options) {
|
||||||
options.push(
|
for (let i =0; i<options.length; i++) {
|
||||||
{
|
let option = options[i];
|
||||||
name: "Sélectionner l'initiative...",
|
if ( option.name == 'COMBAT.CombatantReroll') { // Replace !
|
||||||
condition: true,
|
option.name = "Sélectionner l'initiative...";
|
||||||
icon: '<i class="far fa-question-circle"></i>',
|
option.condition = true;
|
||||||
callback: target => {
|
option.icon = '<i class="far fa-question-circle"></i>';
|
||||||
|
option.callback = target => {
|
||||||
RdDUtility.displayInitiativeMenu(html, target.data('combatant-id'));
|
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);
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "foundryvtt-reve-de-dragon",
|
"name": "foundryvtt-reve-de-dragon",
|
||||||
"title": "Rêve de Dragon",
|
"title": "Rêve de Dragon",
|
||||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||||
"version": "1.3.12",
|
"version": "1.3.13",
|
||||||
"manifestPlusVersion": "1.0.0",
|
"manifestPlusVersion": "1.0.0",
|
||||||
"minimumCoreVersion": "0.7.5",
|
"minimumCoreVersion": "0.7.5",
|
||||||
"compatibleCoreVersion": "0.7.9",
|
"compatibleCoreVersion": "0.7.9",
|
||||||
|
@ -2,9 +2,14 @@
|
|||||||
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
|
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
|
||||||
<div class="rdd-hud-list tokenhudext right">
|
<div class="rdd-hud-list tokenhudext right">
|
||||||
{{#each armes as |arme key|}}
|
{{#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>
|
<label>I:{{arme.name}} {{arme.data.mainInfo}}</label>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/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>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user