mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Fixed collection prep order
This commit is contained in:
parent
6f6ee41f0f
commit
bd5ef8e8d7
4 changed files with 36 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ import * as applications from './module/applications/_module.mjs';
|
||||||
import * as data from './module/data/_module.mjs';
|
import * as data from './module/data/_module.mjs';
|
||||||
import * as models from './module/data/_module.mjs';
|
import * as models from './module/data/_module.mjs';
|
||||||
import * as documents from './module/documents/_module.mjs';
|
import * as documents from './module/documents/_module.mjs';
|
||||||
|
import * as collections from './module/documents/collections/_module.mjs';
|
||||||
import * as dice from './module/dice/_module.mjs';
|
import * as dice from './module/dice/_module.mjs';
|
||||||
import * as fields from './module/data/fields/_module.mjs';
|
import * as fields from './module/data/fields/_module.mjs';
|
||||||
import RegisterHandlebarsHelpers from './module/helpers/handlebarsHelper.mjs';
|
import RegisterHandlebarsHelpers from './module/helpers/handlebarsHelper.mjs';
|
||||||
|
|
@ -36,6 +37,7 @@ CONFIG.Dice.daggerheart = {
|
||||||
|
|
||||||
CONFIG.Actor.documentClass = documents.DhpActor;
|
CONFIG.Actor.documentClass = documents.DhpActor;
|
||||||
CONFIG.Actor.dataModels = models.actors.config;
|
CONFIG.Actor.dataModels = models.actors.config;
|
||||||
|
CONFIG.Actor.collection = collections.DhActorCollection;
|
||||||
|
|
||||||
CONFIG.Item.documentClass = documents.DHItem;
|
CONFIG.Item.documentClass = documents.DHItem;
|
||||||
CONFIG.Item.dataModels = models.items.config;
|
CONFIG.Item.dataModels = models.items.config;
|
||||||
|
|
@ -300,11 +302,12 @@ Hooks.on('chatMessage', (_, message) => {
|
||||||
const difficulty = rollCommand.difficulty;
|
const difficulty = rollCommand.difficulty;
|
||||||
|
|
||||||
const target = getCommandTarget({ allowNull: true });
|
const target = getCommandTarget({ allowNull: true });
|
||||||
const title = flavor ??
|
const title =
|
||||||
traitValue ? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
(flavor ?? traitValue)
|
||||||
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
|
? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||||
})
|
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
|
||||||
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
|
})
|
||||||
|
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
|
||||||
|
|
||||||
enrichedDualityRoll({
|
enrichedDualityRoll({
|
||||||
reaction,
|
reaction,
|
||||||
|
|
|
||||||
|
|
@ -727,6 +727,19 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onUpdate(changes, options, userId) {
|
||||||
|
super._onUpdate(changes, options, userId);
|
||||||
|
|
||||||
|
if (game.user.id === userId) {
|
||||||
|
/* Companion updates */
|
||||||
|
if (this.companion) {
|
||||||
|
if (changes.system.levelData?.level?.current !== undefined) {
|
||||||
|
this.companion.update(this.companion.toObject(), { diff: false, recursive: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _preDelete() {
|
async _preDelete() {
|
||||||
super._preDelete();
|
super._preDelete();
|
||||||
|
|
||||||
|
|
|
||||||
1
module/documents/collections/_module.mjs
Normal file
1
module/documents/collections/_module.mjs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export { default as DhActorCollection } from './actorCollection.mjs';
|
||||||
14
module/documents/collections/actorCollection.mjs
Normal file
14
module/documents/collections/actorCollection.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
export default class DhActorCollection extends foundry.documents.collections.Actors {
|
||||||
|
/** Ensure companions are initialized after all other subtypes. */
|
||||||
|
_initialize() {
|
||||||
|
super._initialize();
|
||||||
|
const companions = [];
|
||||||
|
for (const actor of this.values()) {
|
||||||
|
if (actor.type === 'companion') companions.push(actor);
|
||||||
|
}
|
||||||
|
for (const actor of companions) {
|
||||||
|
this.delete(actor.id);
|
||||||
|
this.set(actor.id, actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue