mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed the migration to respect null for multiclass (#1075)
This commit is contained in:
parent
fbeff1b908
commit
5a38e28a84
1 changed files with 22 additions and 1 deletions
|
|
@ -3,8 +3,13 @@ export async function runMigrations() {
|
||||||
if (!lastMigrationVersion) lastMigrationVersion = '1.0.6';
|
if (!lastMigrationVersion) lastMigrationVersion = '1.0.6';
|
||||||
|
|
||||||
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
|
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
|
||||||
|
const lockedPacks = [];
|
||||||
const compendiumActors = [];
|
const compendiumActors = [];
|
||||||
for (let pack of game.packs) {
|
for (let pack of game.packs) {
|
||||||
|
if (pack.locked) {
|
||||||
|
lockedPacks.push(pack.collection);
|
||||||
|
await pack.configure({ locked: false });
|
||||||
|
}
|
||||||
const documents = await pack.getDocuments();
|
const documents = await pack.getDocuments();
|
||||||
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
||||||
}
|
}
|
||||||
|
|
@ -32,13 +37,23 @@ export async function runMigrations() {
|
||||||
actor.updateEmbeddedDocuments('Item', items);
|
actor.updateEmbeddedDocuments('Item', items);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (let packId of lockedPacks) {
|
||||||
|
const pack = game.packs.get(packId);
|
||||||
|
await pack.configure({ locked: true });
|
||||||
|
}
|
||||||
|
|
||||||
lastMigrationVersion = '1.1.0';
|
lastMigrationVersion = '1.1.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundry.utils.isNewerVersion('1.1.1', lastMigrationVersion)) {
|
if (foundry.utils.isNewerVersion('1.1.1', lastMigrationVersion)) {
|
||||||
|
const lockedPacks = [];
|
||||||
const compendiumClasses = [];
|
const compendiumClasses = [];
|
||||||
const compendiumActors = [];
|
const compendiumActors = [];
|
||||||
for (let pack of game.packs) {
|
for (let pack of game.packs) {
|
||||||
|
if (pack.locked) {
|
||||||
|
lockedPacks.push(pack.collection);
|
||||||
|
await pack.configure({ locked: false });
|
||||||
|
}
|
||||||
const documents = await pack.getDocuments();
|
const documents = await pack.getDocuments();
|
||||||
compendiumClasses.push(...documents.filter(x => x.type === 'class'));
|
compendiumClasses.push(...documents.filter(x => x.type === 'class'));
|
||||||
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
||||||
|
|
@ -46,7 +61,8 @@ export async function runMigrations() {
|
||||||
|
|
||||||
[...compendiumActors, ...game.actors.filter(x => x.type === 'character')].forEach(char => {
|
[...compendiumActors, ...game.actors.filter(x => x.type === 'character')].forEach(char => {
|
||||||
const multiclass = char.items.find(x => x.type === 'class' && x.system.isMulticlass);
|
const multiclass = char.items.find(x => x.type === 'class' && x.system.isMulticlass);
|
||||||
const multiclassSubclass = multiclass.system.subclasses.length > 0 ? multiclass.system.subclasses[0] : null;
|
const multiclassSubclass =
|
||||||
|
multiclass?.system?.subclasses?.length > 0 ? multiclass.system.subclasses[0] : null;
|
||||||
char.items.forEach(item => {
|
char.items.forEach(item => {
|
||||||
if (item.type === 'feature' && item.system.identifier === 'multiclass') {
|
if (item.type === 'feature' && item.system.identifier === 'multiclass') {
|
||||||
const base = item.system.originItemType === 'class' ? multiclass : multiclassSubclass;
|
const base = item.system.originItemType === 'class' ? multiclass : multiclassSubclass;
|
||||||
|
|
@ -72,6 +88,11 @@ export async function runMigrations() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let packId of lockedPacks) {
|
||||||
|
const pack = game.packs.get(packId);
|
||||||
|
await pack.configure({ locked: true });
|
||||||
|
}
|
||||||
|
|
||||||
lastMigrationVersion = '1.1.1';
|
lastMigrationVersion = '1.1.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue