Centralize and expand spoiler handling#221
Open
Hyperseeker wants to merge 2 commits intonornagon:mainfrom
Open
Centralize and expand spoiler handling#221Hyperseeker wants to merge 2 commits intonornagon:mainfrom
Hyperseeker wants to merge 2 commits intonornagon:mainfrom
Conversation
nornagon
requested changes
Feb 24, 2026
Comment on lines
+5
to
+15
| const SPOILER_PREFIXES: ReadonlySet<string> = new Set([ | ||
| "f_vitrified_", | ||
| "f_glassedbody_", | ||
| "t_vitrified_", | ||
| "black_glass_", | ||
| "imperfect_doll_", | ||
| ]); | ||
|
|
||
| const SPOILER_IDS: ReadonlySet<string> = new Set(["mon_dragon_dummy"]); | ||
|
|
||
| const SPOILER_SUFFIXES: ReadonlySet<string> = new Set(["_vitrified"]); |
Owner
There was a problem hiding this comment.
const SPOILER_PATTERNS = [
/^(f_vitrified_|f_glassedbody_|...)|_vitrified$/,
/^mon_dragon_dummy$/,
];
Author
There was a problem hiding this comment.
While I agree that it's cleaner, I don't think it's better per se. Splitting them into named constants means they are easier to maintain for someone who perhaps isn't familiar with handling RegEx. Basically, the less cognitive load contributors have to go through to update the list, the less maintainance you will have to do later.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This PR refactors spoiler handling. Specifically, it does the following:
spoilers.ts), providing an easy way to extend the system in the future<Spoiler />component fromMonster.svelte(where the check had one hardcoded ID) up toThing.svelte, and uses the centralized spoiler check to hide the thing when the check returnstrueThe overall impact of this PR is: it allows for cleaner, unified handling of all spoiler items. (The one exception to that is location loot, as I didn't want to mess with systems I don't understand too much. It should, in theory, be possible to migrate this to the ID-based spoiler check, but I haven't looked into it, as it was out of scope for this PR.)
Related issues
Closes #214
Testing
Ran the dev server locally, searched a few things using default parameters (latest experimental, ASCII tileset, English language). Did not run the tests because they would take 10+ mins per, and I believe the manual testing (see below) should suffice.
Prefix-based hiding
Default (no `?hideNothing`): "No results."
With `?hideNothing`: all black glass items shown
ID-based hiding
Default: "No results."
With `?hideNothing`: ancient red dragon
Suffix-based hiding
(The suffix check is more of a futureproofing than an immediate need. I had to use the full item ID to check it because `_vitrified` is a catch-all for the current black-glass items.)
Default: "No results."
With `?hideNothing`: tree of glass apples
Items that shouldn't be hidden
Default: all relevant items shown
With `?hideNothing`: all relevant items still shown
Locations to hide loot from
Location itself (`mil_base`) is accessible in search
Loot from location (checked `9mmP`) does not appear on the list (hard to showcase since the viewport would not include the search menu no matter how hard I tried)