import { toPrevious } from 'app/actions/Card' ; import { choice } from 'app/actions/Quest' ; import { CombatPhase } from 'app/Constants' ; import { AppStateWithHistory , CardName , SettingsType } from 'app/reducers/StateTypes' ; import { connect } from 'react-redux' ; import Redux from 'redux' ; import { ParserNode } from '../TemplateTypes' ; import Roleplay , { DispatchProps , Props , StateProps } from './Roleplay' ; const mapStateToProps = ( state , ownProps ) : StateProps => { const histIdx = state . _history . length - 2 ; const prevNode = state . _history [ histIdx ] && state . _history [ histIdx ] . quest && state . _history [ histIdx ] . quest . node ; if ( ownProps . node === undefined ) { throw Error ( 'Node not given' ) ; } return { node : ownProps . node , questID : state . quest . details . id , onReturn : ownProps . onReturn , prevNode , settings : state . settings , } ; } ; const mapDispatchToProps = ( dispatch ) : DispatchProps => { return { onChoice : ( settings , node , index ) => { dispatch ( choice ( { node , index } ) ) ; } , onRetry : ( ) => { dispatch ( toPrevious ( { matchFn : ( c , n ) => n . ctx . templates . combat . phase === CombatPhase . drawEnemies , before : true } ) ) ; } , } ; } ; const RoleplayContainer = connect ( mapStateToProps , mapDispatchToProps ) ( Roleplay ) ; export default RoleplayContainer ;