Skip to content

Commit

Permalink
non-alpha identifiers for class scale values
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Jan 17, 2024
1 parent f8a4fae commit 61136a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# NEXT UP

- Better handling of class identifiers for scaling values if they have non-alpha characters.

# 3.7.14

- If generating effects the MidiQoL Confirm Targets and Remove Chat card button settings will be set to "Midi Settings".
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const utils = {
referenceNameString: (str) => {
return str.replace(/[^a-zA-Z0-9]/g, "-")
.replace(/-+/g, "-")
.trim();
.trim()
.replace(/-$/g, '');
},

nameString: (str) => {
Expand Down
7 changes: 4 additions & 3 deletions src/parser/features/DDBFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,19 @@ export default class DDBFeatures {

_setLevelScales() {
this.parsed.forEach((feature) => {
const featureName = utils.referenceNameString(feature.name.toLowerCase());
const featureName = utils.referenceNameString(feature.name).toLowerCase();
const scaleKlass = this.ddbCharacter.raw.classes.find((klass) =>
klass.system.advancement
.some((advancement) => advancement.type === "ScaleValue"
&& advancement.configuration.identifier === featureName
));

if (scaleKlass) {
const identifier = utils.referenceNameString(scaleKlass.system.identifier).toLowerCase();
if (hasProperty(feature, "system.damage.parts") && feature.system.damage.parts.length > 0) {
feature.system.damage.parts[0][0] = `@scale.${scaleKlass.system.identifier}.${featureName}`;
feature.system.damage.parts[0][0] = `@scale.${identifier}.${featureName}`;
} else {
setProperty(feature, "system.damage.parts", [[`@scale.${scaleKlass.system.identifier}.${featureName}`]]);
setProperty(feature, "system.damage.parts", [[`@scale.${identifier}.${featureName}`]]);
}
}
});
Expand Down

0 comments on commit 61136a5

Please sign in to comment.