fix: corrections générateur PNJ Traveller et tests Jest

- validateOptions : remplit les champs manquants et corrige les clés invalides
  (détection précédemment inopérante car getXByKey renvoie l'objet par défaut)
- generateCharacteristics : ne mélange plus le tableau avant affectation,
  la priorité des caractéristiques (high → medium → low) est respectée
- Exports manquants : convertSkillToMgt2eFormat, popRandomItems, ERROR_CODES,
  TravellerNpcError
- Tests : import des globals via @jest/globals (obligatoire en ESM),
  suppression de l'import obsolète buildMgt2eBaseActorSystem,
  attente corrigée pilot.smallCraft, test des doublons aligné sur le
  dédoublonnage réel (noms complets, spécialisations conservées)
- AGENTS.md : section Testing mise à jour
- README.md : ajouté
This commit is contained in:
2026-08-03 21:02:35 +02:00
parent f4ba85bcb9
commit 1c55484bf7
5 changed files with 188 additions and 20 deletions
+9 -4
View File
@@ -146,7 +146,7 @@ const SKILL_MAPPING = {
* @param {string} skillName - Nom de la compétence
* @returns {string} - Nom au format mgt2e
*/
function convertSkillToMgt2eFormat(skillName) {
export function convertSkillToMgt2eFormat(skillName) {
// Vérifier d'abord dans le mapping explicite
if (SKILL_MAPPING[skillName]) {
return SKILL_MAPPING[skillName];
@@ -192,8 +192,9 @@ export function generateCharacteristics(citizenCategoryKey, roleKey) {
const category = getCitizenCategoryByKey(citizenCategoryKey);
const priorities = getCharacteristicPrioritiesForRole(roleKey);
// Cloner et mélanger l'array de base de la catégorie
let characteristicArray = shuffleArray([...category.characteristicArray]);
// Le tableau de base de la catégorie est trié par ordre décroissant :
// on l'attribue tel quel dans l'ordre de priorité (high → medium → low)
let characteristicArray = [...category.characteristicArray];
const characteristics = {};
@@ -726,5 +727,9 @@ export {
getSkillsForRole,
getCharacteristicPrioritiesForRole,
validateOptions,
DEFAULT_OPTIONS
DEFAULT_OPTIONS,
popRandomItems
} from './data/travellerNpcGenerator.js';
// Ré-exporter ERROR_CODES et TravellerNpcError utilisés en interne (proviennent de utils)
export { ERROR_CODES, TravellerNpcError } from './utils/travellerNpcUtils.js';