mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
[V14] 1354 - Armor Effect (#1652)
* Initial * progress * Working armor application * . * Added a updateArmorValue function that updates armoreffects according to an auto order * . * Added createDialog * . * Updated Armor SRD * . * Fixed character sheet armor update * Updated itemconfig * Actions now use createDialog for effects * . * . * Fixed ArmorEffect max being a string * Fixed SRD armor effects * Finally finished the migration ._. * SRD finalization * Added ArmoreEffect.armorInteraction option * Added ArmorManagement menu * Fixed DamageReductionDialog * Fixed ArmorManagement pip syle * feat: add style to armors tooltip, add a style to make armor slot label more clear that was a button and add a tooltip location * . * Removed tooltip on manageArmor * Fixes * Fixed Downtime armor repair * Removed ArmorScore from character data model and instead adding it in basePrep * [Feature] ArmorEffect reworked into ChangeType on BaseEffect (#1739) * Initial * . * Single armor rework start * More fixes * Fixed DamageReductionDialog * Removed last traces of ArmorEffect * . * Corrected the SRD to use base effects again * Removed bare bones armor item * [V14] Refactor ArmorChange schema and fix some bugs (#1742) * Refactor ArmorChange schema and fix some bugs * Add current back to schema * Fixed so changing armor values and taking damage works again * Fixed so that scrolltexts for armor changes work again * Removed old marks on armor.system * Restored damageReductionDialog armorScore.value * Use toggle for css class addition/removal * Fix armor change type choices * Added ArmorChange DamageThresholds --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> * [V14] Armor System ArmorScore (#1744) * Readded so that armor items have their system defined armor instead of using an ActiveEffect * Consolidate armor source retrieval * Fix regression with updating armor when sources are disabled * Simplify armor pip update * Use helper in damage reduction dialog * . * Corrected SRD Armor Items --------- Co-authored-by: Carlos Fernandez <cfern1990@gmail.com> * Updated migrations * Migrations are now not horrible =D --------- Co-authored-by: Murilo Brito <dev.murilobrito@gmail.com> Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com> Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
parent
a3f515cf6d
commit
ef53a7c561
94 changed files with 1961 additions and 545 deletions
|
|
@ -48,6 +48,7 @@ export const preloadHandlebarsTemplates = async function () {
|
|||
'systems/daggerheart/templates/ui/chat/parts/button-part.hbs',
|
||||
'systems/daggerheart/templates/ui/itemBrowser/itemContainer.hbs',
|
||||
'systems/daggerheart/templates/scene/dh-config.hbs',
|
||||
'systems/daggerheart/templates/settings/appearance-settings/diceSoNiceTab.hbs'
|
||||
'systems/daggerheart/templates/settings/appearance-settings/diceSoNiceTab.hbs',
|
||||
'systems/daggerheart/templates/sheets/activeEffect/typeChanges/armorChange.hbs'
|
||||
]);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -246,6 +246,101 @@ export async function runMigrations() {
|
|||
|
||||
lastMigrationVersion = '1.6.0';
|
||||
}
|
||||
|
||||
if (foundry.utils.isNewerVersion('2.0.0', lastMigrationVersion)) {
|
||||
const progress = game.system.api.applications.ui.DhProgress.createMigrationProgress(0);
|
||||
const progressBuffer = 50;
|
||||
|
||||
//#region Data Setup
|
||||
const lockedPacks = [];
|
||||
const itemPacks = game.packs.filter(x => x.metadata.type === 'Item');
|
||||
const actorPacks = game.packs.filter(x => x.metadata.type === 'Actor');
|
||||
|
||||
const getIndexes = async (packs, type) => {
|
||||
const indexes = [];
|
||||
for (const pack of packs) {
|
||||
const indexValues = pack.index.values().reduce((acc, index) => {
|
||||
if (!type || index.type === type) acc.push(index.uuid);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
if (indexValues.length && pack.locked) {
|
||||
lockedPacks.push(pack.collection);
|
||||
await pack.configure({ locked: false });
|
||||
}
|
||||
|
||||
indexes.push(...indexValues);
|
||||
}
|
||||
|
||||
return indexes;
|
||||
};
|
||||
|
||||
const itemEntries = await getIndexes(itemPacks);
|
||||
const characterEntries = await getIndexes(actorPacks, 'character');
|
||||
|
||||
const worldItems = game.items;
|
||||
const worldCharacters = game.actors.filter(x => x.type === 'character');
|
||||
|
||||
/* The async fetches are the mainstay of time. Leaving 1 progress for the sync logic */
|
||||
const newMax = itemEntries.length + characterEntries.length + progressBuffer;
|
||||
progress.updateMax(newMax);
|
||||
|
||||
const compendiumItems = [];
|
||||
for (const entry of itemEntries) {
|
||||
const item = await foundry.utils.fromUuid(entry);
|
||||
compendiumItems.push(item);
|
||||
progress.advance();
|
||||
}
|
||||
|
||||
const compendiumCharacters = [];
|
||||
for (const entry of characterEntries) {
|
||||
const character = await foundry.utils.fromUuid(entry);
|
||||
compendiumCharacters.push(character);
|
||||
progress.advance();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/* Migrate existing effects modifying armor, creating new Armor Effects instead */
|
||||
const migrateEffects = async entity => {
|
||||
for (const effect of entity.effects) {
|
||||
if (effect.system.changes.every(x => x.key !== 'system.armorScore')) continue;
|
||||
|
||||
effect.update({
|
||||
'system.changes': effect.system.changes.map(change => ({
|
||||
...change,
|
||||
type: change.key === 'system.armorScore' ? 'armor' : change.type,
|
||||
value: change.key === 'system.armorScore' ? { current: 0, max: change.value } : change.value
|
||||
}))
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* Migrate existing armors effects */
|
||||
const migrateItems = async items => {
|
||||
for (const item of items) {
|
||||
await migrateEffects(item);
|
||||
}
|
||||
};
|
||||
|
||||
await migrateItems([...compendiumItems, ...worldItems]);
|
||||
progress.advance({ by: progressBuffer / 2 });
|
||||
|
||||
for (const actor of [...compendiumCharacters, ...worldCharacters]) {
|
||||
await migrateEffects(actor);
|
||||
await migrateItems(actor.items);
|
||||
}
|
||||
|
||||
progress.advance({ by: progressBuffer / 2 });
|
||||
|
||||
for (let packId of lockedPacks) {
|
||||
const pack = game.packs.get(packId);
|
||||
await pack.configure({ locked: true });
|
||||
}
|
||||
|
||||
progress.close();
|
||||
|
||||
lastMigrationVersion = '2.0.0';
|
||||
}
|
||||
//#endregion
|
||||
|
||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue