Allow parser to handle some missing fields (costs, forces, categories… #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…, rules, selections, profiles)
Hi, first thanks for making this project. It's great and very helpful.
I noticed that some (actually most) of the roster files I had previously created in battlescribe error out. I think there are some fields that are not always present (arrays of things, listed above), and the code errors out trying to iterate on them. I'm not an expert on the schema though, but this was output by battlescribe itself.
The simplest solution seemed to be defaulting those to empty arrays in each of the relevant Parser functions. You might know of a better approach though. My apologies too if I'm not following typescript best practices as I am still picking that up.
I also added a test ros file to cover this in your test suite. Not sure if you wanted actual 40k references in your repo though, but I didn't have time to scrub it. It is based on the rosz file I was mostly trying. While I was adding that I refactored the test case a bit to be able to add more test files easily in the future, as no doubt there might be other rosz files that cause a problem, potentially. I figure it will be nice to add odd ball ones as they are discovered.