{ "name": "Capacités de combat des Employés", "type": "script", "command": "// =========================================================\n// 1. RECUPERATION DES PC (employés)\n// =========================================================\nconst pcs = game.actors.filter(a => a.type === \"character\" || a.hasPlayerOwner);\nif (pcs.length === 0) {\n ui.notifications.warn(\"Aucun personnage de joueur trouvé.\");\n return;\n}\n\n// =========================================================\n// 2. CONSTRUCTION DU CODE HTML (avec onglets et panel)\n// =========================================================\nlet tabsHtml = `
`;\nlet panelsHtml = ``;\n\n// =========================================================\n// 3. POUR CHAQUE PC\n// =========================================================\npcs.forEach((pc, index) => {\n const sys = pc.system || {};\n \n // ---------------------------\n // Bouton d'onglet\n // ---------------------------\n tabsHtml += `\n \n `;\n \n // ---------------------------\n // SANTE ET ATTAQUES\n // ---------------------------\n const pvVal = sys.sante?.pv?.value ?? 0;\n const pvMax = sys.sante?.pv?.max ?? 0;\n const dv = sys.sante?.dv ?? \"1d6\";\n const attCc = sys.combat?.attaquesCorpsACorps ?? 1;\n const attDist = sys.combat?.attaquesDistance ?? 1;\n\n const items = pc.items ? pc.items.contents : [];\n let armesHtml = \"\";\n let armuresHtml = \"\";\n\n // ---------------------------\n // POUR CHAQUE ARME ET ARMURE\n // ---------------------------\n items.forEach(item => {\n const itemSys = item.system || {};\n \n // ---------------------------\n // --- TRAITEMENT DES ARMES ---\n // ---------------------------\n if (item.type === \"arme\" || item.type === \"weapon\") {\n const typeArme = itemSys.categorie === \"distance\" ? \"Distance\" : \"Corps à corps\";\n const carac = itemSys.caracteristique ? itemSys.caracteristique.toUpperCase() : \"FOR\";\n const mains = itemSys.mains === 2 || itemSys.deuxMains ? \"2 mains\" : \"1 main\";\n const portee = itemSys.portee ? `${itemSys.portee}` : \"Contact\";\n \n let degats = \"\";\n if(itemSys.degatsEstUsageDe) {\n degats = itemSys.degats + \"(Δ)\";\n } else {\n degats = itemSys.degats;\n }\n\n let munitions = \"\";\n if(itemSys.munitionsDelta == null) {\n munitions = \"\";\n } else {\n if(itemSys.munitionsDelta == 0) {\n munitions = \"Epuisées\"; \n } else {\n munitions = \"Δ\" + itemSys.munitionsDelta;\n }\n }\n\n const notes = itemSys.notes ? `

Note: ${itemSys.notes}

` : \"\";\n const desc = item.description || itemSys.description;\n const descHtml = desc && desc.trim() !== \"\" ? `
${desc}
` : \"\";\n\n armesHtml += `\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
${item.name}${typeArme}${carac}${mains}
Dégats :${degats}Portée :${portee}Munitions :${munitions}
Notes :${notes}
Description :${descHtml}
\n
\n
\n
`;\n }\n\n // ---------------------------\n // --- TRAITEMENT DES ARMURES ---\n // ---------------------------\n if (item.type === \"armure\" || item.type === \"armor\") {\n const protection = \"Δ\" + itemSys.delta;\n const protectionRestante = itemSys.resultatProtection;\n const encombrement = itemSys.encombrement;\n \n const notes = itemSys.notes ? `

Note: ${itemSys.notes}

` : \"\";\n const desc = item.description || itemSys.description;\n const descHtml = desc && desc.trim() !== \"\" ? `
${desc}
` : \"\";\n\n armuresHtml += `\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
${item.name}
Protection Δ :${protection}Encombrement :${encombrement}
Protection restante :${protectionRestante}
Notes :${notes}
Description :${descHtml}
\n
\n
\n
`;\n }\n });\n\n if (!armesHtml) armesHtml = `

Aucune arme répertoriée.

`;\n if (!armuresHtml) armuresHtml = `

Aucune armure répertoriée.

`;\n\n panelsHtml += `\n
\n
\n
\n DV\n

${dv}

\n
\n
\n PV\n

${pvVal} / ${pvMax}

\n
\n
\n Attaques CàC\n

⚔️ x${attCc}

\n
\n
\n Attaques Dist.\n

🏹 x${attDist}

\n
\n
\n\n
\n

Armes

\n
${armesHtml}
\n
\n\n
\n

Armures

\n
${armuresHtml}
\n
\n
`;\n});\n\ntabsHtml += `
`;\n\nlet content = `\n
\n
\n

Capacités de Combat des Employés

\n ${tabsHtml}\n
\n ${panelsHtml}\n
\n
\n
\n`;\n\n// =========================================================\n// 4. AFFICHE DE LA BOITE DE DIALOGUE\n// =========================================================\nconst dialog = await foundry.applications.api.DialogV2.wait({\n window: {\n title: \"Capacités de Combat des Employés\",\n icon: \"fa-solid fa-shield-halved\"\n },\n content: content,\n classes: [\"fvtt-donjon-et-cie\"],\n buttons: [\n {\n action: \"close\",\n label: \"Fermer\",\n icon: \"fas fa-xmark\",\n callback: () => ({action: \"Fermer\"})\n } \n ],\n rejectClose: false,\n render: (event, dialog) => {\n const root = dialog.element;\n \n const triggers = root.querySelectorAll('.custom-tab-trigger');\n const panels = root.querySelectorAll('.custom-pc-panel');\n \n const setActiveTab = (activeId) => {\n triggers.forEach(btn => {\n const pcId = btn.getAttribute('data-pc-id');\n if (pcId === activeId) {\n btn.style.setProperty('background', '#8b2e17', 'important');\n btn.style.setProperty('color', '#ffffff', 'important');\n btn.style.setProperty('border-color', '#561d0e', 'important');\n } else {\n btn.style.setProperty('background', 'rgba(226, 208, 177, 0.6)', 'important');\n btn.style.setProperty('color', '#221b18', 'important');\n btn.style.setProperty('border-color', '#561d0e', 'important');\n }\n });\n \n panels.forEach(panel => {\n const panelId = panel.getAttribute('id');\n if (panelId === `panel-pc-${activeId}`) {\n panel.style.setProperty('display', 'block', 'important');\n } else {\n panel.style.setProperty('display', 'none', 'important');\n }\n });\n };\n \n if (triggers.length > 0) {\n const firstId = triggers[0].getAttribute('data-pc-id');\n setActiveTab(firstId);\n }\n \n triggers.forEach(btn => {\n btn.addEventListener('click', (e) => {\n e.preventDefault();\n e.stopPropagation();\n const pcId = btn.getAttribute('data-pc-id');\n setActiveTab(pcId);\n });\n });\n }, \n submit: (result) => {}\n});", "img": "icons/environment/people/charge.webp", "author": "eibNkxM8PO50SgGM", "scope": "global", "folder": null, "flags": {}, "_stats": { "compendiumSource": null, "duplicateSource": null, "exportSource": { "worldId": "donjon-et-cie", "uuid": "Macro.u5wLzazd4Ls5Dv0b", "coreVersion": "13.351", "systemId": "fvtt-donjon-et-cie", "systemVersion": "14.0.14" }, "coreVersion": "13.351", "systemId": "fvtt-donjon-et-cie", "systemVersion": "14.0.14", "createdTime": 1780351858617, "modifiedTime": 1780424697902, "lastModifiedBy": "eibNkxM8PO50SgGM" }, "ownership": { "default": 0 } }