import { Slot , Ability , SlotId } from '../types' ; export const findSlotByEntityName = ( slotName , slots ) => slots . find ( ( slot ) => slot . name === slotName ) ; export const findAbilityByName = ( abilityName , abilities ) => abilities . find ( ability => ability . name === abilityName ) ; export const findSlotInAbilitiesBySlotId = ( abilities , slotId ) : Slot | undefined => { const ability = abilities . find ( ability => ability . name === slotId . abilityName ) ; if ( ! ability ) { return ; } const slot = ability . slots . find ( slot => slot . name === slotId . slotName ) ; return slot ; } ; export const findIndexOfSlotIdsBySlotId = ( array , slotId ) : number => array . findIndex ( ( arrId ) => { return arrId . abilityName === slotId . abilityName && arrId . slotName === slotId . slotName ; } ) ; export const findInSlotIdItemBySlotId = < T extends SlotId > ( array , slotId ) : T => array . find ( arrSlotId => { return arrSlotId . abilityName === slotId . abilityName && arrSlotId . slotName === slotId . slotName ; } ) as T ;