diff --git a/5e_artisanal_database/tools/combat_tracker/index.html b/5e_artisanal_database/tools/combat_tracker/index.html index 03f56e198..9707adf4a 100644 --- a/5e_artisanal_database/tools/combat_tracker/index.html +++ b/5e_artisanal_database/tools/combat_tracker/index.html @@ -321,6 +321,7 @@

Combat Tracker

+ @@ -339,6 +340,80 @@

Combat Tracker

let monsterSources = []; let selectedSource = ''; +// Conditions system +const CONDITIONS = { + 'Blinded': 'πŸ™ˆ', + 'Charmed': '😍', + 'Deafened': 'πŸ™‰', + 'Exhaustion': 'πŸ₯΅', + 'Frightened': '😱', + 'Grappled': '⛓️', + 'Incapacitated': '🚫', + 'Invisible': '🌫️', + 'Paralyzed': 'πŸ₯Ά', + 'Petrified': 'πŸͺ¨', + 'Poisoned': '🀒', + 'Prone': 'πŸ›Œ', + 'Restrained': 'πŸ•ΈοΈ', + 'Stunned': 'πŸ’«', + 'Unconscious': '😴' +}; + +// Function to sync data to player view +function syncToPlayerView() { + const syncData = { + combatants: combatants.map(c => ({ + name: c.name, + initiative: c.initiative, + id: c.id, + currentHp: c.currentHp, + maxHp: c.maxHp, + conditions: c.conditions || [] + })), + currentTurnIndex: currentTurnIndex, + timestamp: Date.now() + }; + + localStorage.setItem('combatTrackerSync', JSON.stringify(syncData)); + console.log('Synced to player view:', syncData); +} + +// Add condition to combatant +function addCondition(combatantId, condition) { + const combatant = combatants.find(c => c.id === combatantId); + if (combatant) { + if (!combatant.conditions) combatant.conditions = []; + if (!combatant.conditions.includes(condition)) { + combatant.conditions.push(condition); + renderCombatTable(); + syncToPlayerView(); + } + } +} + +// Remove condition from combatant +function removeCondition(combatantId, condition) { + const combatant = combatants.find(c => c.id === combatantId); + if (combatant && combatant.conditions) { + combatant.conditions = combatant.conditions.filter(c => c !== condition); + renderCombatTable(); + syncToPlayerView(); + } +} + +// Generate conditions display HTML +function getConditionsDisplay(combatant) { + if (!combatant.conditions || combatant.conditions.length === 0) { + return ''; + } + + return combatant.conditions.map(condition => + `${CONDITIONS[condition]}` + ).join(''); +} + // Load monster data from included JavaScript function loadMonstersFromJS() { try { @@ -652,21 +727,34 @@

Combat Tracker

function renderCombatTable() { const tbody = document.getElementById('combatBody'); tbody.innerHTML = ''; - + combatants.forEach((combatant, index) => { const row = document.createElement('tr'); - + // Add current turn highlighting if (index === currentTurnIndex && combatants.length > 0) { row.classList.add('current-turn'); } - + + // Create conditions dropdown + const conditionsDropdown = ` + + `; + row.innerHTML = ` + ` : ''} `; - + tbody.appendChild(row); }); + + // Sync to player view after rendering + syncToPlayerView(); } function modifyHp(id, amount) { @@ -1001,4 +1092,4 @@

Combat Tracker

- \ No newline at end of file + diff --git a/5e_artisanal_database/tools/combat_tracker/player-facing.html b/5e_artisanal_database/tools/combat_tracker/player-facing.html new file mode 100644 index 000000000..30dae6d31 --- /dev/null +++ b/5e_artisanal_database/tools/combat_tracker/player-facing.html @@ -0,0 +1,249 @@ + + + + + + Combat Tracker - Player View + + + + +
+

Combat Tracker

+
+ + +
+
+ +
+ +
+ +

Connecting to DM tracker...

+ + +
Conditions Init Name AC${conditionsDropdown}
- + ${getConditionsDisplay(combatant)} + ${getMonsterLink(combatant)}
@@ -684,9 +772,12 @@

Combat Tracker

-