Skip to content

[D&D 4E] New Feature: Manual power reordering - #15376

Draft
twmccart wants to merge 3 commits into
Roll20:masterfrom
twmccart:dnd4e-power-reordering
Draft

[D&D 4E] New Feature: Manual power reordering#15376
twmccart wants to merge 3 commits into
Roll20:masterfrom
twmccart:dnd4e-power-reordering

Conversation

@twmccart

Copy link
Copy Markdown

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.

  • The pull request title clearly contains the name of the sheet I am editing.
  • The pull request title clearly states the type of change I am submitting (New Sheet/New Feature/Bugfix/etc.).

Pull Request Content

  • The pull request makes changes to files in only one sub-folder.
  • The pull request does not contain changes to any json files in the translations folder (translation.json is permitted)
  • The pull request does not, without express prior permission from affected parties, include any material that could be considered to infringe on a Publisher's intellectual property rights, such as logos, images, rules text or other rules 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:

  • The sheet worker logic was extracted from the sheet as it ships and exercised against a stand-in attribute store, covering: reindexing on move (including that power-1- never matches power-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.
  • Structural checks on the generated markup: all 100 cards received their buttons, power 1 has no up button and power 100 no down button, the card count and div balance are unchanged, and every new data-i18n key resolves in translation.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 removed
  • D&D_4E.css — styling for the new controls
  • translation.json — new English keys (source file only; nothing under translations/)
  • README.md — documents reordering and the slot-reference caveat

twmccart and others added 3 commits August 14, 2026 01:23
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>
@roll20deploy

Copy link
Copy Markdown
Contributor

Character Sheet Info Roll20 Internal Use only.

@twmccart

twmccart commented Aug 14, 2026

Copy link
Copy Markdown
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.

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.

2 participants