import { event } from 'app/actions/Quest' ; import { getContentSets } from 'app/actions/Settings' ; import { MAX_ADVENTURER_HEALTH } from 'app/Constants' ; import { EventParameters } from 'app/reducers/QuestTypes' ; import { AppStateWithHistory } from 'app/reducers/StateTypes' ; import { connect } from 'react-redux' ; import Redux from 'redux' ; import { getCardTemplateTheme } from '../Template' ; import { ParserNode } from '../TemplateTypes' ; import { mapStateToProps as mapStateToPropsBase } from './Types' ; import Victory , { DispatchProps , StateProps } from './Victory' ; const mapStateToProps = ( state , ownProps ) : StateProps => { const node = ownProps . node ; if ( ! node ) { throw Error ( 'Incomplete props given' ) ; } const combat = node . ctx . templates . combat ; let victoryParameters = { heal : MAX_ADVENTURER_HEALTH , loot : true , xp : true , } ; const parsedParams = node . getEventParameters ( 'win' ) ; if ( parsedParams !== null ) { victoryParameters = parsedParams ; } return { ... mapStateToPropsBase ( state , ownProps ) , combat , victoryParameters , theme : getCardTemplateTheme ( state . quest . node ) , contentSets : getContentSets ( state . settings , state . multiplayer ) , } ; } ; const mapDispatchToProps = ( dispatch ) : DispatchProps => { return { onEvent : ( node , evt ) => { dispatch ( event ( { node , evt } ) ) ; } , } ; } ; export default connect ( mapStateToProps , mapDispatchToProps ) ( Victory ) ;