forked from public/foundryvtt-reve-de-dragon
		
	retravail sur les competences; - standardiser les noms de fichiers de templates - méthodes classify pour construire une multimap par type - méthodes pour charger les entrées du compendium - méthodes spécifiques au compétences déplacées
		
			
				
	
	
		
			28 lines
		
	
	
		
			759 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			759 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
 | |
| /* -------------------------------------------- */
 | |
| export class RdDItem {
 | |
| 
 | |
|   /* -------------------------------------------- */
 | |
|   static buildItemsClassification(items) {
 | |
|     return RdDItem.classify(items, it => it.type)
 | |
|   }
 | |
| 
 | |
|   static classify(items, classifier = it => it.type, transform = it => it) {
 | |
|     let itemsBy = {};
 | |
|     RdDItem.classifyInto(itemsBy, items, classifier, transform);
 | |
|     return itemsBy;
 | |
|   }
 | |
| 
 | |
|   static classifyInto(itemsBy, items, classifier = it => it.type, transform = it => it) {
 | |
|     for (const item of items) {
 | |
|       const classification = classifier(item);
 | |
|       let list = itemsBy[classification];
 | |
|       if (!list) {
 | |
|         list = [];
 | |
|         itemsBy[classification] = list;
 | |
|       }
 | |
|       list.push(transform(item));
 | |
|     }
 | |
|   }
 | |
| 
 | |
| } |