import { join } from 'path' ; import { zipObject } from 'lodash' ; import { category } from '../util/category' ; import { directories } from '../util/directories' ; import { write } from '../util/write' ; import { find } from '../util/translate' ; import { width } from '../util/width' ; const count = [ '1' , '2' , '3' , '4' , '5' , '6' ] ; const materials = count . map ( ( number ) => `material${ number }` ) ; const recipes = category ( 'Recipes' , directories . sanitized ) ; const tabs = [ 'Craft' , 'Dresses' , 'Event Items' , 'ETC' , 'Furniture' , 'Floors' , 'Fossils' , 'Plants' , 'Shells' , 'Tools' , 'Walls' , ] ; for ( const recipe of recipes ) { const names = materials . map ( ( key ) => recipe [ key ] ) . filter ( ( element ) => ! ! element ) ; const amount = count . map ( ( key ) => recipe [ key ] ) . filter ( ( element ) => ! ! element ) ; recipe . materials = zipObject ( names , amount ) ; for ( const key of [ ... count , ... materials ] ) { delete recipe [ key ] ; } const translations = names . map ( ( name ) => find ( name , tabs ) ) ; recipe . materialsTranslations = zipObject ( names , translations ) ; } write ( join ( directories . sanitized , 'Recipes.json' ) , recipes , width ( 'Recipes' ) ) ;