Skip to content

Centralize and expand spoiler handling#221

Open
Hyperseeker wants to merge 2 commits intonornagon:mainfrom
Hyperseeker:refactor-spoiler-flow
Open

Centralize and expand spoiler handling#221
Hyperseeker wants to merge 2 commits intonornagon:mainfrom
Hyperseeker:refactor-spoiler-flow

Conversation

@Hyperseeker
Copy link
Copy Markdown

@Hyperseeker Hyperseeker commented Feb 21, 2026

Overview

This PR refactors spoiler handling. Specifically, it does the following:

  • centralizes all spoiler IDs in a single location (spoilers.ts), providing an easy way to extend the system in the future
  • moves the <Spoiler /> component from Monster.svelte (where the check had one hardcoded ID) up to Thing.svelte, and uses the centralized spoiler check to hide the thing when the check returns true
  • updates location loot display to use location IDs from the spoiler file

The 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."

localhost_5173_search_f_vitrified_

With `?hideNothing`: all black glass items shown

localhost_5173_search_f_vitrified__hideNothing
ID-based hiding

Default: "No results."

localhost_5173_search_mon_dragon_dummy

With `?hideNothing`: ancient red dragon

localhost_5173_search_f_vitrified__hideNothing (1)
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."

localhost_5173_search_t_tree_apple_vitrified

With `?hideNothing`: tree of glass apples

localhost_5173_search__vitrified_hideNothing
Items that shouldn't be hidden

Default: all relevant items shown

localhost_5173_search_ar-15

With `?hideNothing`: all relevant items still shown

localhost_5173_search_ar-15_hideNothing
Locations to hide loot from

Location itself (`mil_base`) is accessible in search

localhost_5173_search_t_tree_apple_vitrified (1)

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)

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"]);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const SPOILER_PATTERNS = [
  /^(f_vitrified_|f_glassedbody_|...)|_vitrified$/,
  /^mon_dragon_dummy$/,
];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hide black glass objects

2 participants