Files
fvtt-donjon-et-cie/macros/fvtt-Macro-caracteristiques-des-employes.json
T
2026-06-03 19:20:09 +02:00

30 lines
7.2 KiB
JSON

{
"name": "Caractéristiques des Employés",
"type": "script",
"command": "// =========================================================\n// 1. RECUPERER LES PJ (les employés)\n// =========================================================\nconst pcs = game.actors.filter(a => a.type === \"character\" || a.hasPlayerOwner);\n\nif (pcs.length === 0) {\n ui.notifications.warn(\"Aucun personnage de joueur trouvé.\");\n return;\n}\n\n// =========================================================\n// 2. CONSTRUCTION DU CONTENU DE LA BOITE DE DIALOGUE\n// =========================================================\nlet content = `\n<div class=\"fvtt-donjon-et-cie dnc-sheet\" style=\"padding: 5px;\">\n <div class=\"sheet-card\">\n <h2>Caractéristiques des Employés</h2>\n <table style=\"width: 100%; border-collapse: collapse; font-size: 0.9rem; background: unset;\">\n <thead>\n <tr style=\"border-bottom: 2px solid #5b4634; text-align: left; color: #6d5a4f; font-size: 0.8rem; text-transform: uppercase; background: antiquewhite;\">\n <th style=\"padding: 0.5rem 0.25rem;\">Nom / Concept</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">PV</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">DV</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">FOR</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">DEX</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">CON</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">INT</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">SAG</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">CHA</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">Suspicion</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">Avertissements</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">Missions réussies</th>\n <th style=\"padding: 0.5rem 0.25rem; text-align: center;\">Traits</th>\n </tr>\n </thead>\n <tbody>\n`;\n\n// =========================================================\n// 3. POUR CHAQUE PERSONNAGE-JOUEUR\n// =========================================================\nfor (let pc of pcs) {\n const sys = pc.system;\n if (!sys || !sys.caracteristiques) continue;\n\n const name = pc.name;\n const concept = sys.concept || \"\";\n const pvVal = sys.sante?.pv?.value ?? 0;\n const pvMax = sys.sante?.pv?.max ?? 0;\n const dv = sys.sante?.dv ?? 0;\n \n // Caractéristiques\n const force = sys.caracteristiques.force?.value ?? 0;\n const dex = sys.caracteristiques.dexterite?.value ?? 0;\n const con = sys.caracteristiques.constitution?.value ?? 0;\n const int = sys.caracteristiques.intelligence?.value ?? 0;\n const sag = sys.caracteristiques.sagesse?.value ?? 0;\n const cha = sys.caracteristiques.charisme?.value ?? 0;\n \n // Profil\n const suspicion = sys.profil?.suspicion ?? 0;\n const avertissements = sys.profil?.avertissements ?? 0;\n const missionsReussies = sys.profil?.missionsReussies ?? 0;\n\n // Traits\n const items = pc.items ? pc.items.contents : [];\n let traits = \"\";\n let first = true;\n items.forEach(item => {\n const itemSys = item.system || {};\n if (item.type === \"trait\" || item.type === \"???\") {\n if(first) {\n first = false;\n } else {\n traits += \", \";\n }\n traits += item.name;\n }\n });\n\n content += `\n <tr style=\"border-bottom: 1px dashed rgba(91, 70, 52, 0.45); color: #221b18;\">\n <td style=\"padding: 0.5rem 0.25rem;\">\n <strong style=\"color: #8b2e17;\">${name}</strong><br>\n <span style=\"font-size: 0.75rem; color: #6d5a4f; italic\">${concept}</span>\n </td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center; font-weight: bold;\">\n <span class=\"${pvVal <= 2 ? 'warning' : ''}\">${pvVal}</span> / ${pvMax}\n </td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${dv}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${force}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${dex}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${con}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${int}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${sag}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${cha}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${missionsReussies}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center; font-weight: bold; color: ${suspicion > 0 ? '#842c2c' : '#221b18'};\">${suspicion}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center; font-weight: bold; color: ${avertissements > 0 ? '#842c2c' : '#221b18'};\">${avertissements}</td>\n <td style=\"padding: 0.5rem 0.25rem; text-align: center;\">${traits}</td>\n </tr>\n `;\n}\n\ncontent += `\n </tbody>\n </table>\n </div>\n</div>\n`;\n\n// =========================================================\n// 4. AFFICHAGE DE LA BOITE DE DIALOGUE\n// =========================================================\nconst dialog = await foundry.applications.api.DialogV2.wait({\n window: {\n title: \"Caractéristiques des Employés\",\n icon: \"fa-solid fa-users\"\n },\n content: content,\n classes: [\"fvtt-donjon-et-cie\"], // Applique le fond et le style global de la fenêtre\n buttons: [\n {\n action: \"close\",\n label: \"Fermer\",\n icon: \"fas fa-xmark\",\n callback: (event, button, dialog) => {\n return {action: \"Fermer\"};\n }\n } \n ],\n rejectClose: false,\n render: (event, dialog) => {\n const root = dialog.element;\n this._dialogElement = root;\n }, \n submit: (result) => {}\n});",
"img": "icons/environment/people/group.webp",
"author": "eibNkxM8PO50SgGM",
"scope": "global",
"folder": null,
"flags": {},
"_stats": {
"compendiumSource": null,
"duplicateSource": null,
"exportSource": {
"worldId": "donjon-et-cie",
"uuid": "Macro.Y8xsVOLKNcMnIOAr",
"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": 1780347363797,
"modifiedTime": 1780424175701,
"lastModifiedBy": "eibNkxM8PO50SgGM"
},
"ownership": {
"default": 0
}
}