fix(eherbs): v2.2.1 warn when stocking a survival kit with no stock % set - #2474
Merged
mrhoribu merged 1 commit intoSep 14, 2026
Merged
Conversation
… set A Survivalist's Kit holds (tier * 25) + 25 doses per slot, while the default min_stock_doses targets are herb sack sized (4-7 doses for scar herbs, 25-50 for common ones). determine_survival_kit only rescales those targets to the kit's capacity when a stock % is configured; with the setting left empty it returns early and the sack defaults stand. A kit satisfies those defaults on its own, so get_current_stock builds an empty shopping list and stocking reports "You are fully stocked with herbs at this location." while buying nothing. Nothing indicates the setting is the cause. Warn instead of guessing at a percentage, since changing what an unset setting means would alter behavior for existing users. The check lives in stock_herbs rather than at startup because it only matters to stocking, and is guarded on the kit because a plain herb sack's defaults are already correct. Stocking still proceeds, it just explains itself now, and the message includes a clickable command to set the value. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
mrhoribu
approved these changes
Sep 14, 2026
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.
Problem
Reported in Discord:
;eherbs stockreports a Survivalist's Kit is fully stocked and buys nothing. The cause is an empty Stock to % of Capacity setting, which gives no indication that it is the problem.A Survivalist's Kit holds
(tier * 25) + 25doses per herb slot. The defaultmin_stock_dosestargets are herb sack sized — 4–7 doses for scar herbs, 25–50 for the common ones.determine_survival_kitrescales those targets to the kit's capacity, but only past this guard:With the field empty,
"".to_iis0, the method returns early, and the sack defaults stand. A kit exceeds them on its own, soget_current_stockfindstotal_doses >= min_stock_doses[bippity]for every category, the shopping list comes back empty, and stocking prints "You are fully stocked with herbs at this location."Fix
Warn rather than guess at a percentage. Changing what an unset setting means would silently alter behavior for every existing user, which did not seem appropriate for a script this long-established, so the default is untouched — stocking still proceeds and still reports fully stocked, it just explains why now and points at the existing
;eherbs set stock <percent>command with a clickable link.Two guards keep it narrow:
stock_herbs, not at startup. Plenty of people use eherbs to tend wounds and never stock; they should not be nagged about a setting irrelevant to them. It is also placed after the Icemule/Pinefar earlyexitso it does not fire on a run that is about to bail.Testing
ruby -cpasses.rubocop --force-exclusion scripts/eherbs.lic— no offenses.origin/master(096a093); the only diff is the new helper, its one call site, and the version/changelog bump.Note — two unrelated bugs in
determine_survival_kitSpotted while reading the method, deliberately left alone to keep this focused. Happy to open a separate issue or PR.
tiercan be nil. Line 2993 uses a trailing-modifierif, so when theCapacity: n/5line is absent from the analyze outputtierstays nil and(tier * 25)raisesNoMethodError. It also readsRegexp.last_match(1)after thelines.any?block has finished, which happens to work only becauseany?short-circuits on the matching line.Double scaling on redetect.
EHerbs.data[:stock]is mutated in place and@@min_stock_dosesis overwritten rather than recomputed from the defaults. On the redetect path the already-scaled values get scaled again — 50% applied twice yields 25%. A fix would mean keeping the literal hash as a frozen constant and.dup-ing it before each rescale.🤖 Generated with Claude Code