import { WolfState , PromptSlot , SlotId , Ability , Slot , SlotStatus , MessageData , OnFillStackItem } from '../types' ; import { findIndexOfSlotIdsBySlotId } from '../helpers' ; export const getPromptedSlotId = ( state ) : SlotId => state . promptedSlotStack [ 0 ] ; export const getSlotBySlotId = ( abilities , slotInfo ) : Slot | undefined => { const ability = abilities . find ( ( ability ) => ability . name === slotInfo . abilityName ) ; if ( ! ability ) { return ; } const foundSlot = ability . slots . find ( ( slot ) => slot . name === slotInfo . slotName ) ; return foundSlot ; } ; export const isPromptStatus = ( state ) => { return state . promptedSlotStack [ 0 ] ? state . promptedSlotStack [ 0 ] . prompted : false ; } ; export const isFocusedAbilitySet = ( state ) => state . focusedAbility ; export const getSlotTurnCount = ( state , slotId ) : number => { const promptSlot = state . promptedSlotStack . find ( ( promptSlot ) => promptSlot . slotName === slotId . slotName && promptSlot . abilityName === slotId . abilityName ) ; if ( promptSlot ) { return promptSlot . turnCount ; } return 0 ; } ; export const getTargetAbility = ( abilities , targetAbility ) : Ability | undefined => { return abilities . find ( ( ability ) => ability . name === targetAbility ) ; } ; export const getRequestingSlotIdFromCurrentSlotId = ( state , slotId ) : SlotId => { const slotIndex = findIndexOfSlotIdsBySlotId ( state . slotStatus , slotId ) ; const slot = state . slotStatus [ slotIndex ] ; if ( ! slot . requestingSlot ) { throw new Error ( `You did not request any slot to use this slot to confirm` ) ; } return { abilityName : slot . abilityName , slotName : slot . requestingSlot } ; } ; export const getMessageData = ( state ) : MessageData => state . messageData ; export const getRunOnFillStack = ( state ) : OnFillStackItem [ ] => state . runOnFillStack ;