import { action } from 'typesafe-actions'; import { PokemonAppActionTypes, ThunkResult } from 'app/types'; import { AttackTypeEffectiveness } from 'app/models/Config'; import { CombatMoveStats, IMaxStats } from 'app/models/Pokemon'; export const setIsInterruption = (isInterruption : boolean) => action(PokemonAppActionTypes.SET_IS_INTERRUPTION, { isInterruption }); export const setMaxPossibleStats = (maxStats : IMaxStats) => action(PokemonAppActionTypes.SET_MAX_STATS, { maxStats }); export const setAttackTypeEffectiveness = (attackTypeEffectiveness : AttackTypeEffectiveness) => action(PokemonAppActionTypes.SET_COMBAT_MOVE_STATS, { attackTypeEffectiveness }); export const setCombatMoveStats = (combatMoves : CombatMoveStats) => action(PokemonAppActionTypes.SET_COMBAT_MOVE_STATS, { combatMoves }); export const fetchConfig = ( ) : ThunkResult> => { return async (dispatch, getState, extraArguments) => { const config = await extraArguments.services.pokemonService.getConfig(); dispatch(setMaxPossibleStats(config.maxPossibleStats)); dispatch(setAttackTypeEffectiveness(config.attackTypeEffectiveness)); dispatch(setCombatMoveStats(config.combatMoves)); }; };