Fixed 'null' in WordScaleQuality lists not behaving as you'd expect #40
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.
One of the features of
QualityDefinition
is that if theformat()
method returnsnull
, nothing at all is written and the quality isn't displayed at all. You would expect that if one of the items in aWordScaleQuality
isnull
, then that quality shouldn't be displayed at all as long as the quality is at that point in the scale; this is useful, for instance, for a quality that should only display if it is greater than some quantity (Eg, tracking wounds the player character suffered), a quality that depletes until it disappears entirely (Eg, tracking how much of a finite resource the player character has left), or a quality that is only visible if it is exceptional (Eg, in a game with many stats, showing only stats that aren't average).Unfortunately, Undum currently doesn't behave this way. The reason why is line 479 in undum.js:
Because mod is always a string, this line type coerces
this.values[val]
into a string, so thatnull
becomes'null'
. I've added a line to check fornull
here and return an actualnull
value if that's the case, thus making it so the expected behaviour actually happens, making the interface here more consistent with the other QualityDefinition variants.