mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
.
This commit is contained in:
parent
07f9d4a9bc
commit
05cc148e91
7 changed files with 77 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs'
|
||||||
import { registerCountdownHooks } from './module/data/countdowns.mjs';
|
import { registerCountdownHooks } from './module/data/countdowns.mjs';
|
||||||
import {
|
import {
|
||||||
handlebarsRegistration,
|
handlebarsRegistration,
|
||||||
|
runMigrations,
|
||||||
settingsRegistration,
|
settingsRegistration,
|
||||||
socketRegistration
|
socketRegistration
|
||||||
} from './module/systemRegistration/_module.mjs';
|
} from './module/systemRegistration/_module.mjs';
|
||||||
|
|
@ -168,6 +169,8 @@ Hooks.on('ready', async () => {
|
||||||
game.user.setFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.welcomeMessage, true);
|
game.user.setFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.welcomeMessage, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runMigrations();
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.once('dicesoniceready', () => {});
|
Hooks.once('dicesoniceready', () => {});
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,6 @@ export const gameSettings = {
|
||||||
Fear: 'ResourcesFear'
|
Fear: 'ResourcesFear'
|
||||||
},
|
},
|
||||||
LevelTiers: 'LevelTiers',
|
LevelTiers: 'LevelTiers',
|
||||||
Countdowns: 'Countdowns'
|
Countdowns: 'Countdowns',
|
||||||
|
LastMigrationVersion: 'LastMigrationVersion'
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,20 @@ export default class DHFeature extends BaseDataItem {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /** @inheritDoc */
|
||||||
|
// _initializeSource(data, options={}) {
|
||||||
|
// const { originItemType, isMulticlass } = data;
|
||||||
|
// const base = (originItemType && this.parent?.parent?.type === 'character') ? this.parent.parent.items._source.find(x => x.type === originItemType && Boolean(isMulticlass) === x.system.isMulticlass) : null;
|
||||||
|
// if(base) {
|
||||||
|
// const feature = base.system.features.find(x => x.item && x.item === this.parent.uuid);
|
||||||
|
// if(feature && data.identifier !== 'multiclass') {
|
||||||
|
// data.identifier = feature.type;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return super._initializeSource(data, options);
|
||||||
|
// }
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
/**@override */
|
/**@override */
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
export { preloadHandlebarsTemplates as handlebarsRegistration } from './handlebars.mjs';
|
export { preloadHandlebarsTemplates as handlebarsRegistration } from './handlebars.mjs';
|
||||||
export * as settingsRegistration from './settings.mjs';
|
export * as settingsRegistration from './settings.mjs';
|
||||||
export * as socketRegistration from './socket.mjs';
|
export * as socketRegistration from './socket.mjs';
|
||||||
|
export { runMigrations } from './migrations.mjs';
|
||||||
|
|
|
||||||
50
module/systemRegistration/migrations.mjs
Normal file
50
module/systemRegistration/migrations.mjs
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
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.0.7')) {
|
||||||
|
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.0.7';
|
||||||
|
}
|
||||||
|
|
||||||
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionCompare = (current, target) => {
|
||||||
|
const currentSplit = current.split('.').map(x => Number.parseInt(x));
|
||||||
|
const targetSplit = target.split('.').map(x => Number.parseInt(x));
|
||||||
|
for (var i = 0; i < currentSplit.length; i++) {
|
||||||
|
if (currentSplit[i] < targetSplit[i]) return true;
|
||||||
|
if (currentSplit[i] > targetSplit[i]) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
@ -91,6 +91,12 @@ const registerMenus = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const registerNonConfigSettings = () => {
|
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, {
|
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers, {
|
||||||
scope: 'world',
|
scope: 'world',
|
||||||
config: false,
|
config: false,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "daggerheart",
|
"id": "daggerheart",
|
||||||
"title": "Daggerheart",
|
"title": "Daggerheart",
|
||||||
"description": "An unofficial implementation of the Daggerheart system",
|
"description": "An unofficial implementation of the Daggerheart system",
|
||||||
"version": "1.0.6",
|
"version": "1.0.7",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "13",
|
"minimum": "13",
|
||||||
"verified": "13.347",
|
"verified": "13.347",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue