/* -------------------------------------------- */ import { RdDUtility } from "./rdd-utility.js"; /* -------------------------------------------- */ export class RdDTokenHud { /* -------------------------------------------- */ static addTokenHudExtensions( app, html, data ) { let token = canvas.tokens.get(data._id); // Affichage seulement si le token est un combat if ( token.inCombat) { this.addInitiativeTokenTip(html, token); } } /* -------------------------------------------- */ static async addInitiativeTokenTip(html, token ) { // Helper actor and sanity check let actor = token.actor; if (actor === undefined) return; // Get combatant stuff let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id ); if ( combatant ) { // Create space for Hud Extensions next to combat icon let divTokenHudExt = '
'; html.find('.control-icon.combat').wrap(divTokenHudExt); let armesList = RdDUtility.buildArmeList( combatant ); let htmlList = ""; console.log("Token !!!", combatant, armesList); for( let armeIndex=0; armeIndex'; htmlList += '
'; } let hudInitiative = $(htmlList); //let hudInitiative = $('
' + Dague + '
'); //let hudInitiative = $('
Dague
'); 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 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 ); }); } } }