Fix: Activation des spécialités dans les fiches PNJ Traveller

- Correction de setSkillLevel pour créer les spécialités manquantes automatiquement
- Mapping corrigé: Pilot-Spacecraft -> pilot.vaisseaux_spatiaux (pluriel)
- Résout le problème où les spécialités comme 'Vaisseaux spatiaux' n'étaient pas activées

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-05-28 00:53:20 +02:00
parent 9453c15d58
commit d8c61458ea
7 changed files with 34 additions and 6 deletions
Binary file not shown.
Binary file not shown.
+6
View File
@@ -46,3 +46,9 @@
2026/05/28-00:37:26.109453 7f3e6effd6c0 Delete type=2 #64 2026/05/28-00:37:26.109453 7f3e6effd6c0 Delete type=2 #64
2026/05/28-00:37:26.109722 7f3e6effd6c0 Delete type=2 #66 2026/05/28-00:37:26.109722 7f3e6effd6c0 Delete type=2 #66
2026/05/28-00:37:26.109828 7f3e6effd6c0 Delete type=2 #68 2026/05/28-00:37:26.109828 7f3e6effd6c0 Delete type=2 #68
2026/05/28-00:48:03.393850 7f3e6effd6c0 Level-0 table #71: started
2026/05/28-00:48:03.411976 7f3e6effd6c0 Level-0 table #71: 1806724 bytes OK
2026/05/28-00:48:03.419030 7f3e6effd6c0 Delete type=0 #67
2026/05/28-00:52:05.605289 7f3e6effd6c0 Level-0 table #73: started
2026/05/28-00:52:05.629208 7f3e6effd6c0 Level-0 table #73: 1856591 bytes OK
2026/05/28-00:52:05.635297 7f3e6effd6c0 Delete type=0 #70
Binary file not shown.
+25 -4
View File
@@ -112,13 +112,34 @@ export function setSkillLevel(skills, skillFqn, level) {
if (!skillId || !skills?.[skillId]) return skills; if (!skillId || !skills?.[skillId]) return skills;
const numericLevel = Number(level ?? 0); const numericLevel = Number(level ?? 0);
const skill = foundry.utils.mergeObject(skills[skillId], { trained: numericLevel > 0 || skills[skillId].trained }); let skill = foundry.utils.deepClone(skills[skillId]);
if (specialityId && skill.specialities?.[specialityId]) { // Marquer la compétence comme entraînée si niveau > 0
skill.specialities[specialityId] = foundry.utils.mergeObject(skill.specialities[specialityId], { skill.trained = numericLevel > 0 || skill.trained;
if (specialityId) {
// Créer l'objet specialities s'il n'existe pas
if (!skill.specialities) {
skill.specialities = {};
}
// Créer la spécialité si elle n'existe pas
if (!skill.specialities[specialityId]) {
skill.specialities[specialityId] = {
value: 0,
trained: false,
default: skill.default || null
};
}
// Appliquer le niveau à la spécialité
skill.specialities[specialityId] = foundry.utils.mergeObject(
skill.specialities[specialityId],
{
value: Math.max(Number(skill.specialities[specialityId].value ?? 0), numericLevel), value: Math.max(Number(skill.specialities[specialityId].value ?? 0), numericLevel),
}); trained: true
}
);
} else { } else {
// Compétence sans spécialité
skill.value = Math.max(Number(skill.value ?? 0), numericLevel); skill.value = Math.max(Number(skill.value ?? 0), numericLevel);
} }
+2 -1
View File
@@ -58,7 +58,8 @@ const MODULE_ID = 'mgt2-compendium-amiral-denisov';
const SKILL_MAPPING = { const SKILL_MAPPING = {
// Pilotage - MgT2e a une compétence "pilot" (confirmé par les références) // Pilotage - MgT2e a une compétence "pilot" (confirmé par les références)
// Corrigé : Small Craft = Petits vaisseaux (pas Aéronef léger) // Corrigé : Small Craft = Petits vaisseaux (pas Aéronef léger)
'Pilot-Spacecraft': 'pilot.vaisseau_spatial', // Vaisseaux spatiaux au pluriel (correspond au nom dans mgt2e)
'Pilot-Spacecraft': 'pilot.vaisseaux_spatiaux',
'Pilot-Small Craft': 'pilot.petits_vaisseaux', 'Pilot-Small Craft': 'pilot.petits_vaisseaux',
'Pilot': 'pilot', 'Pilot': 'pilot',
'Flyer': 'pilot.aeronef_atmospherique', 'Flyer': 'pilot.aeronef_atmospherique',