mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
[Fix] Subclass Links (#1069)
* Attempt at making subclass aware of its class * Update compendium classes/subclasses * Fixed multiclass * Update compenidum browser subclass class filter * Added migration for subclass.linkedClass * Using foundry's isNewer function rather than custom one * Added migration for existing actor features --------- Co-authored-by: Dapoolp <elcatnet@gmail.com>
This commit is contained in:
parent
0b2694b007
commit
46ea4addd0
41 changed files with 479 additions and 391 deletions
|
|
@ -1,10 +1,8 @@
|
|||
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')) {
|
||||
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
|
||||
const compendiumActors = [];
|
||||
for (let pack of game.packs) {
|
||||
const documents = await pack.getDocuments();
|
||||
|
|
@ -37,5 +35,45 @@ export async function runMigrations() {
|
|||
lastMigrationVersion = '1.1.0';
|
||||
}
|
||||
|
||||
if (foundry.utils.isNewerVersion('1.1.1', lastMigrationVersion)) {
|
||||
const compendiumClasses = [];
|
||||
const compendiumActors = [];
|
||||
for (let pack of game.packs) {
|
||||
const documents = await pack.getDocuments();
|
||||
compendiumClasses.push(...documents.filter(x => x.type === 'class'));
|
||||
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
||||
}
|
||||
|
||||
[...compendiumActors, ...game.actors.filter(x => x.type === 'character')].forEach(char => {
|
||||
const multiclass = char.items.find(x => x.type === 'class' && x.system.isMulticlass);
|
||||
const multiclassSubclass = multiclass.system.subclasses.length > 0 ? multiclass.system.subclasses[0] : null;
|
||||
char.items.forEach(item => {
|
||||
if (item.type === 'feature' && item.system.identifier === 'multiclass') {
|
||||
const base = item.system.originItemType === 'class' ? multiclass : multiclassSubclass;
|
||||
if (base) {
|
||||
const baseFeature = base.system.features.find(x => x.item.name === item.name);
|
||||
if (baseFeature) {
|
||||
item.update({
|
||||
system: {
|
||||
multiclassOrigin: true,
|
||||
identifier: baseFeature.type
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const worldClasses = game.items.filter(x => x.type === 'class');
|
||||
for (let classVal of [...compendiumClasses, ...worldClasses]) {
|
||||
for (let subclass of classVal.system.subclasses) {
|
||||
await subclass.update({ 'system.linkedClass': classVal.uuid });
|
||||
}
|
||||
}
|
||||
|
||||
lastMigrationVersion = '1.1.1';
|
||||
}
|
||||
|
||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue