mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Merged with development
This commit is contained in:
commit
19a07139ff
548 changed files with 4997 additions and 2887 deletions
|
|
@ -34,7 +34,7 @@ export const preloadHandlebarsTemplates = async function () {
|
|||
'systems/daggerheart/templates/ui/chat/parts/damage-part.hbs',
|
||||
'systems/daggerheart/templates/ui/chat/parts/target-part.hbs',
|
||||
'systems/daggerheart/templates/ui/chat/parts/button-part.hbs',
|
||||
|
||||
'systems/daggerheart/templates/ui/itemBrowser/itemContainer.hbs',
|
||||
'systems/daggerheart/templates/scene/dh-config.hbs'
|
||||
]);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
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 lockedPacks = [];
|
||||
const compendiumActors = [];
|
||||
for (let pack of game.packs) {
|
||||
if (pack.locked) {
|
||||
lockedPacks.push(pack.collection);
|
||||
await pack.configure({ locked: false });
|
||||
}
|
||||
const documents = await pack.getDocuments();
|
||||
compendiumActors.push(...documents.filter(x => x.type === 'character'));
|
||||
}
|
||||
|
|
@ -34,8 +37,119 @@ export async function runMigrations() {
|
|||
actor.updateEmbeddedDocuments('Item', items);
|
||||
});
|
||||
|
||||
for (let packId of lockedPacks) {
|
||||
const pack = game.packs.get(packId);
|
||||
await pack.configure({ locked: true });
|
||||
}
|
||||
|
||||
lastMigrationVersion = '1.1.0';
|
||||
}
|
||||
|
||||
if (foundry.utils.isNewerVersion('1.1.1', lastMigrationVersion)) {
|
||||
const lockedPacks = [];
|
||||
const compendiumClasses = [];
|
||||
const compendiumActors = [];
|
||||
for (let pack of game.packs) {
|
||||
if (pack.locked) {
|
||||
lockedPacks.push(pack.collection);
|
||||
await pack.configure({ locked: false });
|
||||
}
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
for (let packId of lockedPacks) {
|
||||
const pack = game.packs.get(packId);
|
||||
await pack.configure({ locked: true });
|
||||
}
|
||||
|
||||
lastMigrationVersion = '1.1.1';
|
||||
}
|
||||
|
||||
if (foundry.utils.isNewerVersion('1.2.0', lastMigrationVersion)) {
|
||||
const lockedPacks = [];
|
||||
const compendiumItems = [];
|
||||
for (let pack of game.packs) {
|
||||
if (pack.locked) {
|
||||
lockedPacks.push(pack.collection);
|
||||
await pack.configure({ locked: false });
|
||||
}
|
||||
const documents = await pack.getDocuments();
|
||||
|
||||
compendiumItems.push(...documents.filter(x => x.system?.metadata?.hasActions));
|
||||
compendiumItems.push(
|
||||
...documents
|
||||
.filter(x => x.items)
|
||||
.flatMap(actor => actor.items.filter(x => x.system?.metadata?.hasActions))
|
||||
);
|
||||
}
|
||||
|
||||
const worldItems = game.items.filter(x => x.system.metadata.hasActions);
|
||||
const worldActorItems = Array.from(game.actors).flatMap(actor =>
|
||||
actor.items.filter(x => x.system.metadata.hasActions)
|
||||
);
|
||||
|
||||
const validCostKeys = Object.keys(CONFIG.DH.GENERAL.abilityCosts);
|
||||
for (let item of [...worldItems, ...worldActorItems, ...compendiumItems]) {
|
||||
for (let action of item.system.actions) {
|
||||
const resourceCostIndexes = Object.keys(action.cost).reduce(
|
||||
(acc, index) => (!validCostKeys.includes(action.cost[index].key) ? [...acc, Number(index)] : acc),
|
||||
[]
|
||||
);
|
||||
if (resourceCostIndexes.length === 0) continue;
|
||||
|
||||
await action.update({
|
||||
cost: action.cost.map((cost, index) => {
|
||||
const { keyIsID, ...rest } = cost;
|
||||
if (!resourceCostIndexes.includes(index)) return { ...rest };
|
||||
|
||||
return {
|
||||
...rest,
|
||||
key: 'resource',
|
||||
itemId: cost.key
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (let packId of lockedPacks) {
|
||||
const pack = game.packs.get(packId);
|
||||
await pack.configure({ locked: true });
|
||||
}
|
||||
|
||||
lastMigrationVersion = '1.2.0';
|
||||
}
|
||||
|
||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ const registerMenus = () => {
|
|||
});
|
||||
|
||||
game.settings.registerMenu(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance, {
|
||||
name: game.i18n.localize('DAGGERHEART.SETTINGS.Menu.appearance.title'),
|
||||
name: game.i18n.localize('DAGGERHEART.SETTINGS.Menu.appearance.label'),
|
||||
label: game.i18n.localize('DAGGERHEART.SETTINGS.Menu.appearance.label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.SETTINGS.Menu.appearance.hint'),
|
||||
icon: 'fa-solid fa-palette',
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export const socketEvent = {
|
|||
|
||||
export const GMUpdateEvent = {
|
||||
UpdateDocument: 'DhGMUpdateDocument',
|
||||
UpdateEffect: 'DhGMUpdateEffect',
|
||||
UpdateSetting: 'DhGMUpdateSetting',
|
||||
UpdateFear: 'DhGMUpdateFear',
|
||||
UpdateSaveMessage: 'DhGMUpdateSaveMessage'
|
||||
|
|
@ -37,9 +38,11 @@ export const registerSocketHooks = () => {
|
|||
const document = data.uuid ? await fromUuid(data.uuid) : null;
|
||||
switch (data.action) {
|
||||
case GMUpdateEvent.UpdateDocument:
|
||||
if (document && data.update) {
|
||||
await document.update(data.update);
|
||||
}
|
||||
if (document && data.update) await document.update(data.update);
|
||||
break;
|
||||
case GMUpdateEvent.UpdateEffect:
|
||||
if (document && data.update)
|
||||
await game.system.api.fields.ActionFields.EffectsField.applyEffects.call(document, data.update);
|
||||
break;
|
||||
case GMUpdateEvent.UpdateSetting:
|
||||
await game.settings.set(CONFIG.DH.id, data.uuid, data.update);
|
||||
|
|
@ -78,7 +81,7 @@ export const registerSocketHooks = () => {
|
|||
|
||||
export const registerUserQueries = () => {
|
||||
CONFIG.queries.armorSlot = DamageReductionDialog.armorSlotQuery;
|
||||
CONFIG.queries.reactionRoll = game.system.api.models.actions.actionsTypes.base.rollSaveQuery;
|
||||
CONFIG.queries.reactionRoll = game.system.api.fields.ActionFields.SaveField.rollSaveQuery;
|
||||
};
|
||||
|
||||
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue