#43 : Initiative sur token

This commit is contained in:
sladecraven 2020-12-05 00:37:10 +01:00
parent cf1156f525
commit 8a0213bdc2
2 changed files with 32 additions and 8 deletions

View File

@ -23,16 +23,17 @@ export class RdDTokenHud {
// Get combatant stuff
let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id );
if ( combatant ) {
console.log("Token !!!", combatant);
// Create space for Hud Extensions next to combat icon
let divTokenHudExt = '<div class="tokenhudext right">';
html.find('.control-icon.combat').wrap(divTokenHudExt);
let armesList = RdDUtility.buildArmeList( combatant );
let htmlList = "";
for (let arme of armesList) {
console.log("Token !!!", combatant, armesList);
for( let armeIndex=0; armeIndex<armesList.length; armeIndex++) {
let arme = armesList[armeIndex];
htmlList += '<div class="control-icon tokenhudicon right" title="'+ arme.name +'">';
htmlList += '<label class="hud-text-small" data-combatant-id="'+combatant._id+'" data-arme-id="'+arme._id+'"></i>'+arme.name+'</label>';
htmlList += '<label class="hud-text-small" data-combatant-id="'+combatant._id+'" data-arme-id="'+armeIndex+'"></i>'+arme.name+'</label></div>';
}
let hudInitiative = $(htmlList);
//let hudInitiative = $('<div class="control-icon tokenhudicon right" title="' + TooltipInitiative + '"><i class="fas fa-spinner"></i> ' + Dague + '</div>');
@ -40,11 +41,11 @@ export class RdDTokenHud {
html.find('.control-icon.combat').after(hudInitiative); // Add Initiative and Agility token tip
// Add interactions for Initiative and Agility
hudInitiative.find('label').click(async (event) => {
let armeId = event.currentTarget.attributes['data-arme-id'].value;
let combatantId = event.currentTarget.attributes['data-combatant-id'].value;
let arme = actor.getOwnedItem(armeId);
console.log("CLICKED !", actor, armeId, arme);
RdDUtility.rollInitiativeCompetence( combatantId, arme.data );
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
let combatantId = event.currentTarget.attributes['data-combatant-id'].value;
let arme = armesList[armeIndex];
console.log("CLICKED !", armeIndex, arme);
RdDUtility.rollInitiativeCompetence( combatantId, arme );
});
}
}

View File

@ -630,6 +630,29 @@ ul, li {
margin-left: 4px;
}
/* ======================================== */
.tokenhudext {
display: flex;
flex: 0 !important;
font-family: CaslonPro;
font-weight: 600;
}
.tokenhudext.right {
justify-content: flex-start;
}
.control-icon.tokenhudicon {
width: fit-content;
min-width: 42px;
flex-basis: auto;
padding: 0 8px;
margin: 8px 0px;
}
.control-icon.tokenhudicon.right {
margin-left: 8px;
}
.hud-text-small {
font-size: 0.75rem;
}
/* ======================================== */
.item-checkbox {
height: 25px;