* Gets all class modifiers for a given character * This filters out all modifiers that do not have an entry in the class features passed in * For multiclassing characters, it checks if the given class is the starting class or a multiclass, * then the `.availableToMulticlass` is queried if this
(data, classFeatures, isStartingClass = false)
| 75 | * @param {*} classLevel level requirement up to which the class features should be extracted |
| 76 | */ |
| 77 | function getClassModifiers(data, classFeatures, isStartingClass = false) { |
| 78 | const modifiers = data.modifiers.class.filter(classModifier => { |
| 79 | // check the class from which this modifier came |
| 80 | const componentId = classModifier.componentId; |
| 81 | //const feature = classFeatures.find(feature => feature.id === componentId || chosenOptions.includes(feature.id)); |
| 82 | const feature = classFeatures.find(feature => feature.id === componentId); |
| 83 | if (feature !== undefined) { |
| 84 | const isFeatureAvailable = classModifier.availableToMulticlass ? true : isStartingClass; |
| 85 | console.log( |
| 86 | `${isFeatureAvailable ? " [ AVAIL]" : " [UNAVAIL]"} Modifier found: ${classModifier.friendlyTypeName} (${ |
| 87 | classModifier.friendlySubtypeName |
| 88 | })` |
| 89 | ); |
| 90 | return isFeatureAvailable; |
| 91 | } |
| 92 | return false; |
| 93 | }); |
| 94 | |
| 95 | return modifiers; |
| 96 | } |
| 97 | |
| 98 | function getClassOptionModifiers(data) { |
| 99 |