fix: versatile weapon quick-roll picks d8 button correctly (#1388)#1390
Open
0xguy07 wants to merge 1 commit into
Open
fix: versatile weapon quick-roll picks d8 button correctly (#1388)#13900xguy07 wants to merge 1 commit into
0xguy07 wants to merge 1 commit into
Conversation
…1388) Replace the `action.previousElementSibling !== null` test with a scoped lookup of `.integrated-dice__container` elements within the same `.ddbc-combat-attack__damage` area. Only set `force_versatile = true` when this action is the last of more-than-one container — i.e. the 2-handed/versatile variant — regardless of any sibling label or icon nodes DDB now renders ahead of the first container. Before, on a longsword the d8 button got `force_versatile=true` whenever DDB rendered any node ahead of it in the damage area; that flag flows into rollItem and forces `versatile_choice="two"`, rolling 1d10 instead of 1d8. Console trace from the report: `Executing panel : b20-item-pane false true true` (force_versatile=true) → `Damage to crits : 1d10+7`. AI assistance: root-cause analysis and the closest()/querySelectorAll() rewrite drafted with Claude (Opus 4.7). DOM shape is inferred from the reporter's console output, not verified against a live DDB session. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Replace a fragile
action.previousElementSibling !== nullcheck in the quick-roll wire-up with a scoped lookup inside.ddbc-combat-attack__damage. The previous check incorrectly setforce_versatile = truefor the d8 button on a versatile weapon whenever DDB rendered any label/icon node ahead of the first dice container, so clicking the d8 rolled 1d10 instead of 1d8 (issue #1388).Type of change
What was AI-assisted: Root-cause analysis from the issue's console trace and the
closest()/querySelectorAll()rewrite were drafted with Claude (Anthropic, Opus 4.7). I (the PR author) reviewed the patch and the surroundingactivateQuickRolls/rollItemflow before pushing. No test file is included because this code only runs against the live DDB DOM.Motivation & context
Executing panel : b20-item-pane false true true→force_versatile = truewas passed even though the user clicked the d8. That flag flows intorollItemwhereforce_versatile = trueforcesversatile_choice = "two"(longsword 1d10), producing the reportedDamage to crits : 1d10+7.What changed?
src/dndbeyond/content-scripts/character.js(activateQuickRolls): when wiring upactions_damage, find each action's nearest.ddbc-combat-attack__damageancestor, count the.integrated-dice__containerchildren, and setisVersatile = trueonly when this action is the last of more-than-one container. Behavior matches the original intent ("2-handed/versatile is the second dice container") but is no longer affected by any label/icon/wrapper nodes DDB renders alongside the first container.How to test
git fetch && git checkout fix/versatile-quick-roll-1388npm run build:chrome(or:firefox) and load the unpacked build.1d8 + mods, not1d10.1d10 + mods(2-handed).settings["quick-rolls"]and is unchanged).Reviewer notes
length > 1 && last containeris equivalent topreviousElementSibling !== nullwhenever the dice containers are the only children) so it should be a no-op on DOM shapes where the prior code worked, and only changes behavior on shapes that previously broke. If you have a quick reproducer or DOM snippet handy, it would be useful to confirm.actions_damageare touched.rollItem/force_versatilesemantics are unchanged.