Background import tweaks#106
Conversation
Add skip to background importer. Add missing backgrounds features. Remove formatting from traits.
| const renderStack = []; | ||
| let feature = {}; | ||
| const featureSet = [ | ||
| "Cultural Chameleon", |
There was a problem hiding this comment.
this is not maintainable (and doesn't support homebrew, besides)--the data* already has .data.isFeature = true for features; this should be used instead of matching by name
* the 5etools source data, at any rate; if that doesn't make its way into here, then we should fix that first
There was a problem hiding this comment.
Explicitly tagged the entries as features
| bg.entries.forEach(e => { | ||
| let feature = {}; | ||
| if (e.name && e.name.includes("Feature:")) { | ||
| feature = JSON.parse(JSON.stringify(e)); |
There was a problem hiding this comment.
MiscUtil.copy( ... ) is available instead of JSON.parse(JSON.stringify( ... )), fwiw
There was a problem hiding this comment.
Switched code to use MiscUtil.copy()
| let bond = null; | ||
| let flaw = null; | ||
| const matchCharacteristics = [ | ||
| "Suggested Characteristics", // Most backgrounds |
There was a problem hiding this comment.
this I'm fine with, but it could maybe be a slightly-more-accepting regex /\bcharacteristics\b/i.test(ent.name) to catch any other minor variations. I doubt backgrounds should have other headers with "Characteristics" in them
There was a problem hiding this comment.
Did a little research, seems like includes() is a bit faster, so I used that instead of the regex.
| * @param entry entry to clean up | ||
| * @return cleaned text | ||
| */ | ||
| const _cleanText = function (entry) { |
There was a problem hiding this comment.
use Renderer.stripTags( ... ) instead
There was a problem hiding this comment.
Knew something like that had to exist, but couldn't find it. Thanks!
TheGiddyLimit
left a comment
There was a problem hiding this comment.
Apologies, I wrote this review ages ago and forgot to hit "submit" 😭
| ] | ||
| } | ||
| ] | ||
| ], |
There was a problem hiding this comment.
Apologies, I misunderstood what you were going for here--these should not be tagged as isFeature, as isFeature is reserved for those entries which have "Feature: ..." in the name. These have special significance when choosing a background, as you can swap one "Feature: ..." for another.
Having a way to mark other features as "worthy of import" is good, though, so perhaps "isFeatureLike": true for these, instead?
We should restrict its use to things which are feature-like, however, rather than things which e.g. you roll when choosing a background. So I would tag Feylost's "Feywild Visitor" as "isFeatureLike", but not Feylost's "Fey Mark", for example.
The obvious follow-on from this would be a way to tag "things to roll/pick when choosing background," too, and allowing the user to pick/roll these when choosing a background. That's a big, separate task which we should leave for now--I'd want to restructure background data completely before going any further down that path.
There was a problem hiding this comment.
Although on second thoughts, looking down the list of those you've tagged as isFeature the vast majority fall into the "not really a feature"/"fluff" category, imo.
Which makes me think simply creating a single sheet entry for the entire background with all the text, minus the feature(s) (which can be split out into their own entries), would be preferable.
Add skip to background importer.
Add missing backgrounds features.
Remove formatting from traits.