mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Moved getWorldActor function to utils and updated logic
This commit is contained in:
parent
cf4c546ca2
commit
cc2cf1205c
2 changed files with 24 additions and 23 deletions
|
|
@ -889,4 +889,25 @@ export async function triggerChatRollFx(rolls, options = { whisper: false, blind
|
|||
export function shouldUseHopeFearAutomation(options = { gmAsPlayer: true }) {
|
||||
const { hopeFear } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
||||
return (!game.user.isGM || options.gmAsPlayer) ? hopeFear.players : hopeFear.gm;
|
||||
}
|
||||
|
||||
export async function getWorldActor(baseActor) {
|
||||
if (baseActor.inCompendium) {
|
||||
const worldActorCopy =
|
||||
game.actors.find(x => x._stats.compendiumSource === baseActor.uuid && x.name === baseActor.name);
|
||||
|
||||
if (worldActorCopy)
|
||||
return worldActorCopy;
|
||||
|
||||
const baseActorData = baseActor.toObject();
|
||||
return await game.system.api.documents.DhpActor.create({
|
||||
...baseActorData,
|
||||
_stats: {
|
||||
...baseActorData._stats,
|
||||
compendiumSource: baseActor.uuid
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return baseActor.toObject();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue