Merge branch 'main' into feature/313-preset-measured-templates

This commit is contained in:
Chris Ryan 2025-11-18 15:28:55 +10:00
commit 7d2de14709
81 changed files with 611 additions and 446 deletions

View file

@ -251,15 +251,22 @@ export const adjustRange = (rangeVal, decrease) => {
return range[rangeKeys[newIndex]];
};
export const updateActorTokens = async (actor, update) => {
/**
*
* @param {DhActor} actor - The actor for which all tokens will run a data update.
* @param {string} update - The data update to be applied to all tokens.
* @param {func} updateToken - Optional, specific data update for the non-prototype tokens as a function using the token data. Useful to handle wildcard images where each token has a different image but the prototype has a wildcard path.
*/
export const updateActorTokens = async (actor, update, updateToken) => {
await actor.prototypeToken.update({ ...update });
/* Update the tokens in all scenes belonging to Actor */
for (let token of actor.getDependentTokens()) {
const tokenActor = token.baseActor ?? token.actor;
if (tokenActor?.id === actor.id) {
if (token.id && tokenActor?.id === actor.id) {
await token.update({
...update
...(updateToken ? updateToken(token) : update),
_id: token.id
});
}
}