From 8e971b84c96adc6411a26890d87c31d58a872aaa Mon Sep 17 00:00:00 2001 From: mcbalston <55509718+mcbalston@users.noreply.github.com> Date: Fri, 12 Feb 2021 09:37:10 +0000 Subject: [PATCH 1/3] Update WeaponsDrawn.js Added an additional hook to trigger change of icon state (to idle) on end of combat. --- dist/WeaponsDrawn.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dist/WeaponsDrawn.js b/dist/WeaponsDrawn.js index 04f29d7..e871cc8 100644 --- a/dist/WeaponsDrawn.js +++ b/dist/WeaponsDrawn.js @@ -46,6 +46,7 @@ Hooks.once('ready', function () { Hooks.on('renderTokenConfig', onRenderTokenConfig); Hooks.on('createCombatant', onCreateCombatant); Hooks.on('deleteCombatant', onDeleteCombatant); +Hooks.on('deleteCombat', onDeleteCombat); Hooks.on('createToken', onCreateToken); function onCreateToken (scene, token, _, userId) { @@ -81,6 +82,19 @@ function onDeleteCombatant (combat, combatant, _, userId) { const tokenImgPath = getStateTokenImgPath(actorEntity, false); updateTokenImg(combatant.token._id, true, tokenImgPath, combat.data.scene); } + // Added to return icons to idle state on end of combat +function onDeleteCombat (combat, _, userId) { + if (game.userId !== userId) { + // Only act if we initiated the update ourselves + return; + } + var combatant; + for (combatant of combat.combatants) { + const actorEntity = game.actors.get(combatant.actor.data._id); + const tokenImgPath = getStateTokenImgPath(actorEntity, false); + updateTokenImg(combatant.token._id, true, tokenImgPath, combat.data.scene); + } +} function getStateTokenImgPath (actorEntity, inCombat) { let idleTokenImage = ""; @@ -251,4 +265,4 @@ function onRenderTokenConfig (tokenConfig, html) { // console.log(idleTokens); // console.log(game.scenes); }); -} \ No newline at end of file +} From c286658f570b427f7b448a917042067fa417be78 Mon Sep 17 00:00:00 2001 From: mcbalston <55509718+mcbalston@users.noreply.github.com> Date: Fri, 12 Feb 2021 09:47:39 +0000 Subject: [PATCH 2/3] Revert "Update WeaponsDrawn.js" This reverts commit 8e971b84c96adc6411a26890d87c31d58a872aaa. --- dist/WeaponsDrawn.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/dist/WeaponsDrawn.js b/dist/WeaponsDrawn.js index e871cc8..04f29d7 100644 --- a/dist/WeaponsDrawn.js +++ b/dist/WeaponsDrawn.js @@ -46,7 +46,6 @@ Hooks.once('ready', function () { Hooks.on('renderTokenConfig', onRenderTokenConfig); Hooks.on('createCombatant', onCreateCombatant); Hooks.on('deleteCombatant', onDeleteCombatant); -Hooks.on('deleteCombat', onDeleteCombat); Hooks.on('createToken', onCreateToken); function onCreateToken (scene, token, _, userId) { @@ -82,19 +81,6 @@ function onDeleteCombatant (combat, combatant, _, userId) { const tokenImgPath = getStateTokenImgPath(actorEntity, false); updateTokenImg(combatant.token._id, true, tokenImgPath, combat.data.scene); } - // Added to return icons to idle state on end of combat -function onDeleteCombat (combat, _, userId) { - if (game.userId !== userId) { - // Only act if we initiated the update ourselves - return; - } - var combatant; - for (combatant of combat.combatants) { - const actorEntity = game.actors.get(combatant.actor.data._id); - const tokenImgPath = getStateTokenImgPath(actorEntity, false); - updateTokenImg(combatant.token._id, true, tokenImgPath, combat.data.scene); - } -} function getStateTokenImgPath (actorEntity, inCombat) { let idleTokenImage = ""; @@ -265,4 +251,4 @@ function onRenderTokenConfig (tokenConfig, html) { // console.log(idleTokens); // console.log(game.scenes); }); -} +} \ No newline at end of file From 140ba4fa308e3bf06e1a6234564ea72a12096301 Mon Sep 17 00:00:00 2001 From: mcbalston <55509718+mcbalston@users.noreply.github.com> Date: Fri, 12 Feb 2021 09:54:18 +0000 Subject: [PATCH 3/3] Update WeaponsDrawn.js Added an additional hook (on deleteCombat) to trigger change of icon state (to idle) on end of combat. --- dist/WeaponsDrawn.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/WeaponsDrawn.js b/dist/WeaponsDrawn.js index 04f29d7..0c18c59 100644 --- a/dist/WeaponsDrawn.js +++ b/dist/WeaponsDrawn.js @@ -46,6 +46,7 @@ Hooks.once('ready', function () { Hooks.on('renderTokenConfig', onRenderTokenConfig); Hooks.on('createCombatant', onCreateCombatant); Hooks.on('deleteCombatant', onDeleteCombatant); +Hooks.on('deleteCombat', onDeleteCombat); Hooks.on('createToken', onCreateToken); function onCreateToken (scene, token, _, userId) { @@ -82,6 +83,20 @@ function onDeleteCombatant (combat, combatant, _, userId) { updateTokenImg(combatant.token._id, true, tokenImgPath, combat.data.scene); } + // Return icons to idle state on end of combat + function onDeleteCombat (combat, _, userId) { + if (game.userId !== userId) { + // Only act if we initiated the update ourselves + return; + } + var combatant; + for (combatant of combat.combatants) { + const actorEntity = game.actors.get(combatant.actor.data._id); + const tokenImgPath = getStateTokenImgPath(actorEntity, false); + updateTokenImg(combatant.token._id, true, tokenImgPath, combat.data.scene); + } +} + function getStateTokenImgPath (actorEntity, inCombat) { let idleTokenImage = ""; let combatTokenImage = "";