Skip to content

Commit

Permalink
Merge pull request sw5e-foundry#774 from sw5e-foundry/develop
Browse files Browse the repository at this point in the history
2.3.1.2.6.4
  • Loading branch information
Ikaguia authored Oct 16, 2023
2 parents 26e64c1 + 6efd440 commit 9a06aa0
Show file tree
Hide file tree
Showing 292 changed files with 154 additions and 76 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.1.2.6.4] - 2023-10-16

### Changes

- Art Updates.

### Fixed

- Old NPCs armor class will be properly migrated.
- Class overview journal should once again work.
- Clothing equipment should now have the proper artwork.
- Website Importer should once again work.
- Currency should no longer be reset after any update.
- JournalEntry migration should once again work.

## [2.3.1.2.6.3] - 2023-10-04

### Added
Expand Down
41 changes: 19 additions & 22 deletions module/applications/advancement/item-choice-flow.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,24 @@ export default class ItemChoiceFlow extends ItemGrantFlow {
* @returns {number}
*/
_maxPowerSlotLevel() {
const powercasting = this.advancement.item.powercasting;
let powers;

// For advancements on classes or archetypes, use the largest slot available for that class
if (powercasting) {
const progression = { slot: 0, pact: {} };
const maxPowerLevel = CONFIG.SW5E.SPELL_SLOT_TABLE[CONFIG.SW5E.SPELL_SLOT_TABLE.length - 1].length;
powers = Object.fromEntries(Array.fromRange(maxPowerLevel, 1).map(l => [`power${l}`, {}]));
Actor5e.computeClassProgression(progression, this.advancement.item, { powercasting });
Actor5e.preparePowercastingSlots(powers, powercasting.type, progression);
}

// For all other items, use the largest slot possible
else powers = this.advancement.actor.system.powers;

const largestSlot = Object.entries(powers).reduce((slot, [key, data]) => {
if (data.max === 0) return slot;
const level = parseInt(key.replace("power", ""));
if (!Number.isNaN(level) && level > slot) return level;
return slot;
}, -1);
return Math.max(powers.pact?.level ?? 0, largestSlot);
// TODO: Adapt this to work with force and tech powers
// const powercasting = this.advancement.item.powercasting;
// let powers;

// // For advancements on classes or archetypes, use the largest slot available for that class
// if (powercasting) {
// const progression = { slot: 0, pact: {} };
// const maxPowerLevel = CONFIG.SW5E.SPELL_SLOT_TABLE[CONFIG.SW5E.SPELL_SLOT_TABLE.length - 1].length;
// powers = Object.fromEntries(Array.fromRange(maxPowerLevel, 1).map(l => [`power${l}`, {}]));
// Actor5e.computeClassProgression(progression, this.advancement.item, { powercasting });
// Actor5e.preparePowercastingSlots(powers, powercasting.type, progression);
// }

// // For all other items, use the largest slot possible
// else powers = this.advancement.actor.system.powers;

const attr = this.advancement.actor.system.attributes;
const largestSlot = Math.max(attr.force.maxPowerLevel, attr.tech.maxPowerLevel);
return largestSlot;
}
}
2 changes: 1 addition & 1 deletion module/applications/compendium/compendium-browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class CompendiumBrowser extends Application {
"sw5e.implements": true,
"sw5e.invocations": true,
"sw5e.kits": true,
"sw5e.lightsaberform": true,
"sw5e.lightsaberforms": true,
"sw5e.lightweapons": true,
"sw5e.maneuvers": true,
"sw5e.monsters": true,
Expand Down
2 changes: 1 addition & 1 deletion module/character-importer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default class CharacterImporter {
...(await game.packs.get("sw5e.fightingstyles").getDocuments()),
...(await game.packs.get("sw5e.fightingmasteries").getDocuments()),
...(await game.packs.get("sw5e.gamingsets").getDocuments()),
...(await game.packs.get("sw5e.lightsaberform").getDocuments()),
...(await game.packs.get("sw5e.lightsaberforms").getDocuments()),
...(await game.packs.get("sw5e.modifications").getDocuments()),
...(await game.packs.get("sw5e.kits").getDocuments()),
...(await game.packs.get("sw5e.maneuvers").getDocuments())
Expand Down
20 changes: 20 additions & 0 deletions module/data/actor/npc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export default class NPCData extends CreatureTemplate {
super.migrateData(source);
NPCData.#migrateTypeData(source);
NPCData.#migratePowercastingData(source);
NPCData.#migrateArmorClass(source);
AttributesFields._migrateInitiative(source.attributes);
}

Expand Down Expand Up @@ -286,6 +287,25 @@ export default class NPCData extends CreatureTemplate {

/* -------------------------------------------- */

/**
* Migrate the actor type string to type object.
* @param {object} source The candidate source data from which the model will be constructed.
*/
static #migrateArmorClass(source) {
const ac = source.attributes.ac;
// Remove invalid AC formula strings.
if (ac?.formula) {
try {
const roll = new Roll(ac.formula);
Roll.safeEval(roll.formula);
} catch(e) {
ac.formula = "";
}
}
}

/* -------------------------------------------- */

/**
* Migrate the actor's powercasting data.
* @param {object} source The candidate source data from which the model will be constructed.
Expand Down
3 changes: 2 additions & 1 deletion module/data/shared/currency.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export default class CurrencyTemplate extends foundry.abstract.DataModel {
* @param {object} source The candidate source data from which the model will be constructed.
*/
static #migrateCurrencyData(source) {
if (source.currency === undefined) return;
// If currency if for some reason null, set it to default values
if ([null, undefined].includes(source.currency)) source.currency = { gc: 0 };
if (source.currency === null) source.currency = { gc: 0 };
// If the actor has a numeric currency, then it has not been migrated yet.
else if (Number.isNumeric(source.currency)) source.currency = { gc: source.currency };
// If currency is an object, remove all but galactic credit
Expand Down
1 change: 1 addition & 0 deletions module/documents/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ export default class Actor5e extends Actor {
target.known.max = progression.powersKnownMax;
target.points.max ??= progression.points;
target.level = progression.casterLevel;
target.maxPowerLevel = progression.maxPowerLevel;
target.override = progression.override;
}
}
Expand Down
10 changes: 5 additions & 5 deletions module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ export default class Item5e extends Item {
if (!finalPC) return null;
finalPC.levels = this.isEmbedded ? this.system.levels ?? this.class?.system.levels : null;

// Temp method for determining powercasting type until this data is available directly using advancement
if (CONFIG.SW5E.powercastingTypes[finalPC.progression]) finalPC.type = finalPC.progression;
else finalPC.type = Object.entries(CONFIG.SW5E.powercastingTypes).find(([type, data]) => {
return !!data.progression?.[finalPC.progression];
})?.[0];
// // Temp method for determining powercasting type until this data is available directly using advancement
// if (CONFIG.SW5E.powercastingTypes[finalPC.progression]) finalPC.type = finalPC.progression;
// else finalPC.type = Object.entries(CONFIG.SW5E.powercastingTypes).find(([type, data]) => {
// return !!data.progression?.[finalPC.progression];
// })?.[0];

return finalPC;
}
Expand Down
2 changes: 0 additions & 2 deletions module/migration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,9 @@ export const migrateMacroData = async function(macro, migrationData) {
*/
export function migrateRollTableData(table, migrationData) {
const updateData = {};
_migrateDocumentIcon(table, updateData, migrationData);
if ( !table.results?.length ) return updateData;
const results = table.results.reduce((arr, result) => {
const resultUpdate = {};
_migrateDocumentIcon(result, resultUpdate, migrationData);
if ( !foundry.utils.isEmpty(resultUpdate) ) {
resultUpdate._id = result._id;
arr.push(foundry.utils.expandObject(resultUpdate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "PxfeT33F90WP5TIX",
"name": "Clothes, clandestine",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Clandestine.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956147,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!PxfeT33F90WP5TIX"
Expand Down
6 changes: 3 additions & 3 deletions packs/adventuringgear/equipment/clothing/clothes-common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "SAM5YI80YDJHgL3c",
"name": "Clothes, common",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Common.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956152,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!SAM5YI80YDJHgL3c"
Expand Down
6 changes: 3 additions & 3 deletions packs/adventuringgear/equipment/clothing/clothes-costume.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "bkyNcdlpnoWudg8t",
"name": "Clothes, costume",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Costume.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956167,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!bkyNcdlpnoWudg8t"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "KMrFAW3q2DT2mTQY",
"name": "Clothes, dress uniform",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-DressUniform.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956137,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!KMrFAW3q2DT2mTQY"
Expand Down
6 changes: 3 additions & 3 deletions packs/adventuringgear/equipment/clothing/clothes-fine.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "ZvfO7DRZhF8ynZRc",
"name": "Clothes, fine",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Fine.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956163,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!ZvfO7DRZhF8ynZRc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "pY1HP0FsU7IEdJBp",
"name": "Clothes, traveler's",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-TravelerS.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956186,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!pY1HP0FsU7IEdJBp"
Expand Down
6 changes: 3 additions & 3 deletions packs/adventuringgear/equipment/clothing/sunshades.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "2NPsZXUnyWJERFsp",
"name": "Sunshades",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Sunshades.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -239,10 +239,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493956108,
"modifiedTime": 1695981484712,
"modifiedTime": 1696426246903,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!2NPsZXUnyWJERFsp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "0qX7F9AwnDjdzYhu",
"name": "Clothes, Clandestine (Champion)",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Clandestine.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -209,10 +209,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493964360,
"modifiedTime": 1695981486284,
"modifiedTime": 1696426248333,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!0qX7F9AwnDjdzYhu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "gA0nN5Gn4zdGPkLG",
"name": "Clothes, Clandestine (Exceptional)",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Clandestine.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -209,10 +209,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493964882,
"modifiedTime": 1695981486284,
"modifiedTime": 1696426248333,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!gA0nN5Gn4zdGPkLG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": "IyDGbBYDyQnmN1HI",
"name": "Clothes, Clandestine (Fine)",
"type": "equipment",
"img": "systems/sw5e/packs/Icons/Armor/PHB/AssaultArmor.webp",
"img": "systems/sw5e/packs/Icons/Clothing/Clothes-Clandestine.webp",
"effects": [],
"folder": null,
"sort": 0,
Expand Down Expand Up @@ -209,10 +209,10 @@
},
"_stats": {
"systemId": "sw5e",
"systemVersion": "2.3.1.2.6.1",
"systemVersion": "2.3.1.2.6.3",
"coreVersion": "11.308",
"createdTime": 1674493964606,
"modifiedTime": 1695981486284,
"modifiedTime": 1696426248333,
"lastModifiedBy": "sw5ebuilder0000"
},
"_key": "!items!IyDGbBYDyQnmN1HI"
Expand Down
Loading

0 comments on commit 9a06aa0

Please sign in to comment.