mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Merged with main
This commit is contained in:
commit
e9f7c0c16b
15 changed files with 122 additions and 71 deletions
|
|
@ -1,3 +1,4 @@
|
|||
export { preloadHandlebarsTemplates as handlebarsRegistration } from './handlebars.mjs';
|
||||
export * as settingsRegistration from './settings.mjs';
|
||||
export * as socketRegistration from './socket.mjs';
|
||||
export { runMigrations } from './migrations.mjs';
|
||||
|
|
|
|||
41
module/systemRegistration/migrations.mjs
Normal file
41
module/systemRegistration/migrations.mjs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { versionCompare } from '../helpers/utils.mjs';
|
||||
|
||||
export async function runMigrations() {
|
||||
let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion);
|
||||
if (!lastMigrationVersion) lastMigrationVersion = '1.0.6';
|
||||
|
||||
if (versionCompare(lastMigrationVersion, '1.1.0')) {
|
||||
const compendiumActors = [];
|
||||
for (let pack of game.packs) {
|
||||
const documents = await pack.getDocuments();
|
||||
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
||||
}
|
||||
|
||||
[...compendiumActors, ...game.actors].forEach(actor => {
|
||||
const items = actor.items.reduce((acc, item) => {
|
||||
if (item.type === 'feature') {
|
||||
const { originItemType, isMulticlass, identifier } = item.system;
|
||||
const base = originItemType
|
||||
? actor.items.find(
|
||||
x => x.type === originItemType && Boolean(isMulticlass) === Boolean(x.system.isMulticlass)
|
||||
)
|
||||
: null;
|
||||
if (base) {
|
||||
const feature = base.system.features.find(x => x.item && x.item.uuid === item.uuid);
|
||||
if (feature && identifier !== 'multiclass') {
|
||||
acc.push({ _id: item.id, system: { identifier: feature.type } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
actor.updateEmbeddedDocuments('Item', items);
|
||||
});
|
||||
|
||||
lastMigrationVersion = '1.1.0';
|
||||
}
|
||||
|
||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||
}
|
||||
|
|
@ -91,6 +91,12 @@ const registerMenus = () => {
|
|||
};
|
||||
|
||||
const registerNonConfigSettings = () => {
|
||||
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: String
|
||||
});
|
||||
|
||||
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue