Skip to content

Commit

Permalink
Optional Class feature level constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Jan 10, 2024
1 parent e03f8c8 commit e8148cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# NEXT UP

- Feat Trait advancement for Custom Lineage when importing a character. @gandamir
- Optional Class Features would import without level restrictions since class feature refactor. (v3.7.0) @gandamir

# 3.7.9

Expand Down
17 changes: 12 additions & 5 deletions src/parser/features/DDBFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,18 @@ export default class DDBFeatures {
};
}

async _buildOptionalClassFeatures() {
async _buildOptionalClassFeatures({ requireLevel = true } = {}) {
// optional class features
logger.debug("Parsing optional class features");
if (this.ddbData.classOptions) {
const options = this.ddbData.classOptions
.filter((feat) => {
if (!requireLevel || !hasProperty(feat, "requiredLevel")) return true;
const requiredLevel = getProperty(feat, "requiredLevel");
const klass = this.ddbData.character.classes.find((cls) => cls.definition.id === feat.classId
|| cls.subclassDefinition?.id === feat.classId);
return klass.level >= requiredLevel;
})
.filter((feat) => DDBFeatures.includedFeatureNameCheck(feat.name));
for (const feat of options) {
logger.debug(`Parsing Optional Feature ${feat.name}`);
Expand All @@ -134,21 +141,21 @@ export default class DDBFeatures {

async _buildClassFeatures() {
logger.debug("Parsing class and subclass features");
const ddbClassFeature = new DDBClassFeatures({
this._ddbClassFeatures = new DDBClassFeatures({
ddbData: this.ddbData,
rawCharacter: this.rawCharacter,
});
ddbClassFeature.build();
this._ddbClassFeatures.build();
await this._buildOptionalClassFeatures();

logger.debug("ddbClassFeatures._buildClassFeatures", {
ddbClassFeature,
ddbClassFeature: this._ddbClassFeatures,
this: this,
});

// now we loop over class features and add to list, removing any that match racial traits, e.g. Darkvision
logger.debug("Removing matching traits");
ddbClassFeature.data
this._ddbClassFeatures.data
.forEach((item) => {
const existingFeature = DDBFeatures.getNameMatchedFeature(this.parsed, item);
const duplicateFeature = DDBFeatures.isDuplicateFeature(this.parsed, item);
Expand Down

0 comments on commit e8148cc

Please sign in to comment.