mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Merge branch 'main' into feature/313-preset-measured-templates
This commit is contained in:
commit
7d2de14709
81 changed files with 611 additions and 446 deletions
|
|
@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue