diff --git a/src/App.js b/src/App.js index 84959a6..a9107e6 100644 --- a/src/App.js +++ b/src/App.js @@ -214,7 +214,7 @@ function App() { {!isAuthReady && !error &&

Authenticating...

} ); @@ -354,8 +354,8 @@ function AdminView({ userId }) { } // --- CreateCampaignForm, CharacterManager, EncounterManager, CreateEncounterForm, ParticipantManager, EditParticipantModal, InitiativeControls, DisplayView, Modal, Icons --- -// The rest of the components are identical to the previous version (v0.1.28) and are included below for completeness. -// Only ParticipantManager and DisplayView have minor changes for monster color. +// The rest of the components are identical to the previous version (v0.1.29) and are included below for completeness. +// Only DisplayView has changes for participant rendering logic. function CreateCampaignForm({ onCreate, onCancel }) { const [name, setName] = useState(''); @@ -737,7 +737,7 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { setMaxHp(e.target.value)} className="mt-1 w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-md shadow-sm focus:outline-none focus:ring-sky-500 focus:border-sky-500 sm:text-sm text-white" /> -
{/* Aligned with input bottom */} +
setIsNpc(e.target.checked)} className="h-4 w-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500" />
@@ -752,7 +752,7 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { {campaignCharacters.map(c => )}
-
{/* Spans 2 cols to align with monster layout's 2nd row if needed */} +
setMaxHp(e.target.value)} className="mt-1 w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-md shadow-sm focus:outline-none focus:ring-sky-500 focus:border-sky-500 sm:text-sm text-white" />
@@ -776,7 +776,7 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { const isCurrentTurn = encounter.isStarted && p.id === encounter.currentTurnParticipantId; const isDraggable = (!encounter.isStarted || encounter.isPaused) && tiedInitiatives.includes(Number(p.initiative)); const participantDisplayType = p.type === 'monster' ? (p.isNpc ? 'NPC' : 'Monster') : 'Character'; - let bgColor = p.type === 'character' ? 'bg-sky-800' : (p.isNpc ? 'bg-slate-600' : 'bg-[#8e351c]'); // Custom hex for monster + let bgColor = p.type === 'character' ? 'bg-sky-800' : (p.isNpc ? 'bg-slate-600' : 'bg-[#8e351c]'); if (isCurrentTurn && !encounter.isPaused) bgColor = 'bg-green-600'; return ( @@ -963,13 +963,15 @@ function DisplayView() { const { name, participants, round, currentTurnParticipantId, isStarted, isPaused } = activeEncounterData; let participantsToRender = []; if (participants) { - if (isStarted && activeEncounterData.turnOrderIds?.length > 0 ) { - const inTurnOrderAndActive = activeEncounterData.turnOrderIds.map(id => participants.find(p => p.id === id)).filter(p => p && p.isActive); - const notInTurnOrderButActive = participants.filter(p => p.isActive && !activeEncounterData.turnOrderIds.includes(p.id)).sort((a,b) => { if(a.initiative === b.initiative) { const indexA = participants.findIndex(op => op.id === a.id); const indexB = participants.findIndex(op => op.id === b.id); return indexA - indexB; } return b.initiative - a.initiative; }); - participantsToRender = [...inTurnOrderAndActive, ...notInTurnOrderButActive]; - } else { - participantsToRender = [...participants].filter(p => p.isActive).sort((a, b) => { if (a.initiative === b.initiative) { const indexA = participants.findIndex(p => p.id === a.id); const indexB = participants.findIndex(p => p.id === b.id); return indexA - indexB; } return b.initiative - a.initiative; }); - } + const activeParticipants = participants.filter(p => p.isActive); + participantsToRender = [...activeParticipants].sort((a, b) => { + if (a.initiative === b.initiative) { + const indexA = participants.findIndex(p => p.id === a.id); + const indexB = participants.findIndex(p => p.id === b.id); + return indexA - indexB; + } + return b.initiative - a.initiative; + }); } const displayStyles = campaignBackgroundUrl ? { backgroundImage: `url(${campaignBackgroundUrl})`, backgroundSize: 'cover', backgroundPosition: 'center center', backgroundRepeat: 'no-repeat', minHeight: '100vh' } : { minHeight: '100vh' }; return ( @@ -993,7 +995,7 @@ function DisplayView() { return (
-

{p.name}{p.id === currentTurnParticipantId && isStarted && !isPaused && (Current)}

{/* Ensure monster text is white with new bg */} +

{p.name}{p.id === currentTurnParticipantId && isStarted && !isPaused && (Current)}

Init: {p.initiative}