This repository has been archived on 2023-11-06. You can view files and clone it, but cannot push or open issues or pull requests.
beatsaber-overlay/components/ScoreStats.js
Liam 18098707d1 Added an api
Fixed image loading with said api
2022-02-20 23:52:57 +00:00

36 lines
1.3 KiB
JavaScript

import {Component} from "react";
export default class ScoreStats extends Component {
constructor(params) {
super(params);
}
getAverage(values) {
return values.reduce((p, c) => p + c, 0) / values.length;
}
render() {
const data = this.props.data;
return <div className={'score-stats'}>
<div className={'score-stats-info'}>
<p>{data.percentage}</p>
<p>{data.currentScore.toLocaleString()}</p>
</div>
<p className={'score-stats-average-cut'}>Average Cut</p>
<div className={'score-stats-hands'}>
<div className={'score-stats-left'}>
<p>{this.getAverage(data.leftHand.averagePreSwing).toFixed(2)}</p>
<p>{this.getAverage(data.leftHand.averagePostSwing).toFixed(2)}</p>
<p>{this.getAverage(data.leftHand.averageCut).toFixed(2)}</p>
</div>
<div className={'score-stats-right'}>
<p>{this.getAverage(data.rightHand.averagePreSwing).toFixed(2)}</p>
<p>{this.getAverage(data.rightHand.averagePostSwing).toFixed(2)}</p>
<p>{this.getAverage(data.rightHand.averageCut).toFixed(2)}</p>
</div>
</div>
</div>
}
}