From 33c93ab86b33bf337df628aefa5dbbe4169bbb70 Mon Sep 17 00:00:00 2001 From: robert Date: Sun, 26 Apr 2026 10:37:25 -0400 Subject: [PATCH] Added conditions. --- src/App.js | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index ad7b14a..efe2c73 100644 --- a/src/App.js +++ b/src/App.js @@ -50,6 +50,24 @@ const DEFAULT_INIT_MOD = 0; const MONSTER_DEFAULT_INIT_MOD = 2; const ROLL_DISPLAY_DURATION = 5000; +const CONDITIONS = [ + { id: 'blinded', label: 'Blinded', emoji: 'πŸ™ˆ' }, + { id: 'charmed', label: 'Charmed', emoji: 'πŸ’˜' }, + { id: 'deafened', label: 'Deafened', emoji: 'πŸ”‡' }, + { id: 'exhaustion', label: 'Exhaustion', emoji: '😴' }, + { id: 'frightened', label: 'Frightened', emoji: '😱' }, + { id: 'grappled', label: 'Grappled', emoji: '🀜' }, + { id: 'incapacitated', label: 'Incapacitated', emoji: 'πŸ’«' }, + { id: 'invisible', label: 'Invisible', emoji: 'πŸ‘»' }, + { id: 'paralyzed', label: 'Paralyzed', emoji: '⚑' }, + { id: 'petrified', label: 'Petrified', emoji: 'πŸ—Ώ' }, + { id: 'poisoned', label: 'Poisoned', emoji: '🀒' }, + { id: 'prone', label: 'Prone', emoji: '⬇️' }, + { id: 'restrained', label: 'Restrained', emoji: 'πŸ•ΈοΈ' }, + { id: 'stunned', label: 'Stunned', emoji: 'πŸ’₯' }, + { id: 'unconscious', label: 'Unconscious', emoji: 'πŸ’€' }, +]; + // ============================================================================ // FIREBASE CONFIGURATION // ============================================================================ @@ -769,6 +787,7 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const [itemToDelete, setItemToDelete] = useState(null); const [lastRollDetails, setLastRollDetails] = useState(null); + const [openConditionsId, setOpenConditionsId] = useState(null); const participants = encounter.participants || []; @@ -1057,6 +1076,23 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { } }; + const toggleCondition = async (participantId, conditionId) => { + if (!db) return; + const updatedParticipants = participants.map(p => { + if (p.id !== participantId) return p; + const current = p.conditions || []; + const next = current.includes(conditionId) + ? current.filter(c => c !== conditionId) + : [...current, conditionId]; + return { ...p, conditions: next }; + }); + try { + await updateDoc(doc(db, encounterPath), { participants: updatedParticipants }); + } catch (err) { + console.error("Error updating conditions:", err); + } + }; + const handleDragStart = (e, id) => { setDraggedItemId(id); e.dataTransfer.effectAllowed = 'move'; @@ -1329,6 +1365,47 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { ))} )} + + {/* Active condition badges */} + {(p.conditions || []).length > 0 && ( +
+ {(p.conditions || []).map(cId => { + const cond = CONDITIONS.find(c => c.id === cId); + return cond ? ( + toggleCondition(p.id, cId)} + > + {cond.emoji} {cond.label} + + ) : null; + })} +
+ )} + + {/* Expandable conditions picker */} + {openConditionsId === p.id && ( +
+

Toggle Conditions

+
+ {CONDITIONS.map(cond => { + const active = (p.conditions || []).includes(cond.id); + return ( + + ); + })} +
+
+ )} @@ -1370,6 +1447,13 @@ function ParticipantManager({ encounter, encounterPath, campaignCharacters }) { {p.isActive ? : } )} +