[D&D 4E] New Feature: Manual power reordering - #15376
Draft
twmccart wants to merge 3 commits into
Draft
Conversation
Powers are 100 fixed slots rather than a repeating section, so Roll20's
native drag-to-reorder handle isn't available and there has never been any
way to rearrange them.
Add a small up/down button pair to each power card, in the empty cell that
already opens the card's first header row, backed by a sheet worker that
swaps the two slots' contents. Slot numbering stays fixed and only the
contents move, so existing characters need no migration.
The attack, damage and macro fields store the slot number inside their own
text, so they are reindexed as they move - without that, a power moved into
slot 2 would keep rolling slot 3's attack and damage. Hand-edited macros are
preserved, and references to other powers are left alone.
One caveat, documented in the code and the README: power-<slot>-* names a
slot rather than a power. A token action bound to @{power-3-macro} keeps
resolving after a reorder but now rolls whatever moved into slot 3, so a
button labelled for one power can quietly roll another. That is inherent to
reordering fixed slots - while the handle is a position, moving powers
changes what it points at.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Manual up/down moves are tedious for a character who already has a dozen powers in arbitrary slots. Add a single button above the power cards that groups filled powers into standard 4e usage order - At-Will, Encounter, Daily, Item - and pushes empty slots to the end. The sort is stable, so powers sharing a usage keep whatever order the player arranged by hand. Usage values outside the four known ones sort last rather than being dropped. Moved powers get their attack, damage and macro text reindexed exactly as a manual move does, so everything still rolls itself afterwards, and only slots that actually change are written. The button has no undo, which the label next to it says plainly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A commented-out copy of a single power card sat above the generated cards - 235 lines and 19KB of markup parsed by every client on every sheet load, serving only as a reference for regenerating the cards. It had already gone stale, describing a card without the new reorder buttons, so following it would have produced 100 cards that lose them. Replace it with a short comment recording what actually matters: that the cards are generated and identical, which 18 attributes each one owns, and that the attack, damage and macro fields embed their slot number and must be reindexed by anything that moves a power. Git history keeps the original. No behaviour change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Character Sheet Info Roll20 Internal Use only. |
Author
|
@scarletcs @vectorjohn @iscribble @nogileyelsew @J-Knopf @pigalot I would love your feedback or approval, especially if you are willing to test. I don't currently have a Roll20 Pro account. |
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.
Submission Checklist
Warning
Submission Checklist
Failure to complete this checklist in its entirety will result in your Pull Request being dismissed. Deleting parts of this template (except the new sheet section for existing sheets) counts as failure to complete it. If you have any questions, please feel free to create an issue.
Note
Draft Pull Requests
If you are unclear about any of the rules regarding the creation of character sheets, or need assistance from the Roll20 team, please feel free to create a Draft PR and request feedback. We'd much rather provide assistance than reject a PR.
Pull Request Title
Please format your pull request in the following way:
[Sheet Name] Change Type: Description. For example:[D&D5e] New Feature: Adding dragons to dungeons.Pull Request Content
Changes / Description
Opening as a Draft: the changes have not yet been exercised in a live Roll20 game, and I would rather have that confirmed (and take any feedback on approach) before asking for a merge.
The problem
Powers on this sheet cannot be rearranged at all. The cause is structural rather than a missing control: powers are 100 hardcoded blocks (
power-1-*…power-100-*, 18 attributes each), and Roll20's native drag-to-reorder only exists on<fieldset class="repeating_...">. This sheet already uses repeating sections for inventory and feats, just not for powers.Converting powers to a repeating section is the real fix, but it needs a one-time data migration and changes what external macros resolve to, so it is not something to slip into a small PR. This change makes the existing slots reorderable in place instead, with no migration and no change to any stored attribute name.
What this adds
Up/down buttons on every power card. A sheet worker swaps the two slots' contents. The slot numbering never changes — only what sits in each slot — so existing characters need no migration.
The subtlety worth reviewing: three of the fields (
attack,damage,macro) store their own slot number inside their text, e.g./me uses @{power-3-name}. A naive value swap would leave a power in slot 2 rolling slot 3's attack and damage, so those three are reindexed as they move. Hand-edited macros keep their wording, and a macro that deliberately references some other power is left alone.A "Sort by Usage" button above the cards, grouping filled powers as At-Will → Encounter → Daily → Item and pushing empty slots to the end. The sort is stable, so powers sharing a usage keep the order the player arranged by hand, and unrecognised usage values sort last rather than being dropped. It has no undo, which the label next to it says.
A cleanup commit removing a commented-out copy of a single power card that sat above the generated ones — 235 lines parsed by every client on every sheet load, existing only as a reference for regenerating the cards. It had already gone stale (it described a card without the new buttons, so regenerating from it would have silently dropped them). Replaced with a short comment recording what the cards are and which fields embed their slot number. No behaviour change; git history keeps the original.
Known limitation, documented in the code and README
power-<slot>-*names a slot, not a power. A token action bound to@{power-3-macro}keeps resolving after a reorder, but it now rolls whichever power moved into slot 3 — so a button labelled for one power can quietly roll another. This is inherent to reordering fixed slots: while the handle is a position, moving powers changes what it points at. Players who keep token actions for their powers need to re-check them after rearranging, and the README says so.Testing
No Roll20 game has run this yet — hence the draft. What has been checked:
power-1-never matchespower-10-), a byte-for-byte round trip when a power is moved down and back, hand-edited macros surviving a move, sort grouping and stability, sorting an already-sorted or empty sheet writing nothing, and no power being lost or duplicated by a sort.data-i18nkey resolves intranslation.json.I would particularly welcome a second opinion on whether the up/down button approach is worth having at all, versus going straight to a repeating section. I have a potential conversion on a separate branch and am happy to bring that instead if maintainers would rather take the migration in one go.
Files changed
Only
D&D_4E/:D&D_4E.html— buttons on each card, sort control, sheet workers, dead template removedD&D_4E.css— styling for the new controlstranslation.json— new English keys (source file only; nothing undertranslations/)README.md— documents reordering and the slot-reference caveat