30 lines
14 KiB
JSON
30 lines
14 KiB
JSON
{
|
|
"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 = `<div class=\"macro-nav-container\" style=\"display: flex !important; flex-wrap: wrap !important; gap: 6px !important; margin-bottom: 12px !important; border-bottom: 2px solid #5b4634 !important; padding-bottom: 8px !important;\">`;\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 <button class=\"custom-tab-trigger\" data-pc-id=\"${pc.id}\" style=\"flex: 0 1 auto !important; background: rgba(226, 208, 177, 0.6) !important; border: 1px solid #5b4634 !important; border-radius: 6px !important; color: #221b18 !important; font-weight: bold !important; padding: 6px 12px !important; cursor: pointer !important; font-size: 0.85rem !important;\">\n ${pc.name}\n </button>\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 ? `<p style=\"margin: 0.2rem 0; font-size:0.8rem; font-style:italic; color:#6d5a4f; white-space: pre-wrap !important; word-break: break-word !important;\"><strong>Note:</strong> ${itemSys.notes}</p>` : \"\";\n const desc = item.description || itemSys.description;\n const descHtml = desc && desc.trim() !== \"\" ? `<div style=\"font-size:0.8rem; margin-top:0.25rem; color:#4a3c31; border-left: 2px solid #e2d0b1; padding-left: 0.4rem; white-space: pre-wrap !important; word-break: break-word !important;\">${desc}</div>` : \"\";\n\n armesHtml += `\n <div class=\"item\" style=\"padding: 0.5rem 0; border-top: 1px dashed rgba(91, 70, 52, 0.45);\">\n <div class=\"item-main\">\n <div class=\"item-title-row\">\n <table style=\"table-layout: fixed; padding: unset; margin: unset; background-color: unset;\">\n <tr style=\"border-bottom: 2px solid #5b4634; text-align: left; color: black; font-size: 0.8rem; text-transform: uppercase; background: antiquewhite;\">\n <th colspan=3><strong style=\"color: #8b2e17; font-size: 0.95rem;\">${item.name}</strong></th>\n <th style=\"text-align: left; padding: unset;\"><strong style=\"color: black; font-size: 0.7rem;\">${typeArme}</th>\n <th style=\"text-align: left; padding: unset;\"><strong style=\"color: black; font-size: 0.7rem;\">${carac}</th>\n <th style=\"text-align: left; padding: unset;\"><strong style=\"color: black; font-size: 0.7rem;\">${mains}</th>\n </tr>\n <tr>\n <th style=\"text-align: left; padding: unset;\">Dégats :</th><td style=\"text-align: left; padding: unset;\">${degats}</td>\n <th style=\"text-align: left; padding: unset;\">Portée :</th><td style=\"text-align: left; padding: unset;\">${portee}</td>\n <th style=\"text-align: left; padding: unset;\">Munitions :</th><td style=\"text-align: left; padding: unset;\">${munitions}</td>\n </tr>\n <tr>\n <th style=\"text-align: left; padding: unset; vertical-align: top;\">Notes :</th><td colspan=5 style=\"text-align: left; padding: unset;\">${notes}</td>\n </tr> \n <tr>\n <th style=\"text-align: left; padding: unset; vertical-align: top;\">Description :</th><td colspan=5 style=\"text-align: left; padding: unset;\">${descHtml}</td>\n </tr> \n </table>\n </div>\n </div>\n </div>`;\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 ? `<p style=\"margin: 0.2rem 0; font-size:0.8rem; font-style:italic; color:#6d5a4f; white-space: pre-wrap !important; word-break: break-word !important;\"><strong>Note:</strong> ${itemSys.notes}</p>` : \"\";\n const desc = item.description || itemSys.description;\n const descHtml = desc && desc.trim() !== \"\" ? `<div style=\"font-size:0.8rem; margin-top:0.25rem; color:#4a3c31; border-left: 2px solid #e2d0b1; padding-left: 0.4rem; white-space: pre-wrap !important; word-break: break-word !important;\">${desc}</div>` : \"\";\n\n armuresHtml += `\n <div class=\"item\" style=\"padding: 0.5rem 0; border-top: 1px dashed rgba(91, 70, 52, 0.45);\">\n <div class=\"item-main\">\n <div class=\"item-title-row\">\n <table style=\"table-layout: fixed; padding: unset; margin: unset; background-color: unset;\">\n <tr style=\"border-bottom: 2px solid #5b4634; text-align: left; color: black; font-size: 0.8rem; text-transform: uppercase; background: antiquewhite;\">\n <th colspan=6><strong style=\"color: #8b2e17; font-size: 0.95rem;\">${item.name}</strong></th>\n </tr>\n <tr>\n <th colspan=2 style=\"text-align: left; padding: unset;\">Protection Δ :</th><td style=\"text-align: left; padding: unset;\">${protection}</td>\n <th style=\"text-align: left; padding: unset;\">Encombrement :</th><td style=\"text-align: left; padding: unset;\">${encombrement}</td>\n </tr>\n <tr>\n <th colspan=2 style=\"text-align: left; padding: unset;\">Protection restante :</th><td style=\"text-align: left; padding: unset;\">${protectionRestante}</td>\n </tr> \n <tr>\n <th style=\"text-align: left; padding: unset; vertical-align: top;\">Notes :</th><td colspan=5 style=\"text-align: left; padding: unset;\">${notes}</td>\n </tr> \n <tr>\n <th style=\"text-align: left; padding: unset; vertical-align: top;\">Description :</th><td colspan=5 style=\"text-align: left; padding: unset;\">${descHtml}</td>\n </tr>\n </table>\n </div>\n </div>\n </div>`;\n }\n });\n\n if (!armesHtml) armesHtml = `<p class=\"empty-state\">Aucune arme répertoriée.</p>`;\n if (!armuresHtml) armuresHtml = `<p class=\"empty-state\">Aucune armure répertoriée.</p>`;\n\n panelsHtml += `\n <div class=\"custom-pc-panel\" id=\"panel-pc-${pc.id}\" style=\"width: 100% !important;\">\n <div class=\"identity-grid\" style=\"grid-template-columns: repeat(4, 1fr); margin-bottom: 1rem; gap: 0.75rem;\">\n <div class=\"readonly-field\">\n <span>DV</span>\n <p>${dv}</p>\n </div>\n <div class=\"readonly-field\">\n <span>PV</span>\n <p><strong class=\"${pvVal <= 2 ? 'warning' : ''}\">${pvVal}</strong> / ${pvMax}</p>\n </div>\n <div class=\"readonly-field\">\n <span>Attaques CàC</span>\n <p>⚔️ x${attCc}</p>\n </div>\n <div class=\"readonly-field\">\n <span>Attaques Dist.</span>\n <p>🏹 x${attDist}</p>\n </div>\n </div>\n\n <div class=\"favor-card\" style=\"margin-top: 0; background: rgba(255, 255, 255, 0.45); padding: 0.75rem; border-radius: 10px;\">\n <div class=\"favor-header\"><h2>Armes</h2></div>\n <div class=\"item-list\" style=\"display: flex; flex-direction: column;\">${armesHtml}</div>\n </div>\n\n <div class=\"favor-card\" style=\"margin-bottom: 0; background: rgba(255, 255, 255, 0.45); padding: 0.75rem; border-radius: 10px;\">\n <div class=\"favor-header\"><h2>Armures</h2></div>\n <div class=\"item-list\" style=\"display: flex; flex-direction: column;\">${armuresHtml}</div>\n </div>\n </div>`;\n});\n\ntabsHtml += `</div>`;\n\nlet content = `\n<div class=\"fvtt-donjon-et-cie dnc-sheet\" style=\"padding: 0; min-width: 580px; max-width: 700px;\">\n <div class=\"sheet-card\" style=\"display: flex !important; flex-direction: column !important;\">\n <h2>Capacités de Combat des Employés</h2>\n ${tabsHtml}\n <div class=\"macro-panels-container\" style=\"width:100% !important;\">\n ${panelsHtml}\n </div>\n </div>\n</div>\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
|
|
}
|
|
} |