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
RealFascinated aac2c7027e Updated
Added documentation to methods
Fixed avatars not initially loading
Just generally cleaned up the codebase
2022-04-02 07:01:58 +01:00

42 lines
1.5 KiB
JavaScript

import {Component} from "react";
export default class ScoreStats extends Component {
constructor(params) {
super(params);
}
/**
* Returns the average of the provided numbers list
*
* @param {List<Number>} hitValues
* @returns The average value
*/
getAverage(hitValues) {
return hitValues.reduce((p, c) => p + c, 0) / hitValues.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>
}
}