/** * Copyright (c) 2017 Tomek Wójcik * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ import React from "react"; import {connect} from "react-redux"; import underscore from "underscore"; import ChartComponent from "../components/ChartComponent"; import ContainerComponent from "../components/ContainerComponent"; import ItemIconComponent from "../components/ItemIconComponent"; import LoaderComponent from "../components/LoaderComponent"; import PowerupIconComponent from "../components/PowerupIconComponent"; import WeaponIconComponent from "../components/WeaponIconComponent"; import {cleanup, loadData} from "../actions/playerGame"; class PlayerGameView extends React.PureComponent { constructor (props) { super(props); this.chartConfig = { "credits": { "enabled": false } }; } componentDidMount () { this.props.dispatch(loadData( this.props.dispatch, this.props.params.player, this.props.params.game )); } componentWillUnmount () { this.props.dispatch(cleanup()); } render () { return (

{this.props.params.player} stats on {this.props.map}

Weapons

{underscore.keys(this.props.weaponStats).length == 0 && } {underscore.map( underscore.keys(this.props.weaponStats), (key, index) => { let stats = this.props.weaponStats[key]; return ( ); } )}
Weapon Shots Hits Kills Accuracy
No stats :(
{stats.shots} {stats.hits} {stats.kills} {stats.accuracy}

Items

{underscore.keys(this.props.itemStats).length == 0 && } {underscore.map( underscore.keys(this.props.itemStats), (key, index) => { let value = this.props.itemStats[key]; return ( ); } )}
Item Pickups
No stats :(
{value}

Powerups

{underscore.keys(this.props.powerupStats).length == 0 && } {underscore.map( underscore.keys(this.props.powerupStats), (key, index) => { let stats = this.props.powerupStats[key]; return ( ); } )}
Item Pickups Total time [s]
No stats :(
{stats[0]} {stats[1]}
); } } PlayerGameView.propTypes = { loading: React.PropTypes.bool.isRequired, map: React.PropTypes.string.isRequired, weaponStats: React.PropTypes.object.isRequired, itemStats: React.PropTypes.object.isRequired, powerupStats: React.PropTypes.object.isRequired, scoreChartSeries: React.PropTypes.array.isRequired, damageChartSeries: React.PropTypes.array.isRequired, totalsChartSeries: React.PropTypes.array.isRequired, params: React.PropTypes.object.isRequired }; const mapStateToProps = (state, props) => { return { loading: state.playerGame.loading, map: state.playerGame.map, weaponStats: state.playerGame.weaponStats, itemStats: state.playerGame.itemStats, powerupStats: state.playerGame.powerupStats, scoreChartSeries: state.playerGame.scoreChartSeries, damageChartSeries: state.playerGame.damageChartSeries, totalsChartSeries: state.playerGame.totalsChartSeries, params: props.params }; }; const reduxContainer = connect(mapStateToProps)(PlayerGameView); export default reduxContainer;