fix(BUG-15): DisplayView no longer re-sorts participants by initiative

DisplayView called sortParticipantsByInitiative() on visibleParticipants,
ignoring DM drag order. 1-list model = participants[] IS display source.
After cross-init drag, player view diverged from AdminView/turnOrderIds.

Repro: round 4 replay. [reorder Summon1(10)→before Merchant(11)] made
turnOrderIds = [...,Summon2,Summon1,Merchant,OrcBoss]. AdminView correct.
DisplayView re-sorted = Summon2,Merchant,Summon1 (init order) = visually
Merchant appeared between Summon2 and Summon1, NOT at end. DM confused.

Fix: removed sort. DisplayView now renders participants[] order directly
(filter inactive monsters only), matching AdminView line 1222.

Test: RED → GREEN (src/tests/DisplayView.drag-order.test.js). Seeds 3
monsters in drag order [High:20, Low:10, Mid:11]. Asserts DOM order =
participants[] order, not init-sorted. No DisplayView regressions.
This commit is contained in:
david raistrick
2026-07-01 17:31:40 -04:00
parent d73405753a
commit 58ae04b400
3 changed files with 68 additions and 3 deletions
+4 -3
View File
@@ -2500,9 +2500,10 @@ function DisplayView() {
let participantsToRender = [];
if (participants) {
// Hide inactive monsters (pre-staged/summoned reserves) from the player view
const visibleParticipants = participants.filter(p => p.isActive || p.type !== 'monster');
participantsToRender = sortParticipantsByInitiative(visibleParticipants, visibleParticipants);
// 1-list model: participants[] IS the display order (DM drag = source of
// truth). Do NOT re-sort by initiative — that diverges from AdminView /
// turnOrderIds after any cross-init drag (BUG-15).
participantsToRender = participants.filter(p => p.isActive || p.type !== 'monster');
}
const displayStyles = campaignBackgroundUrl