Change how cut values are handled

This commit is contained in:
Liam 2022-10-21 12:39:42 +01:00
parent 792c92c526
commit f687d9878e
2 changed files with 26 additions and 53 deletions

@ -40,12 +40,12 @@ export default class Overlay extends Component {
percentage: "100.00%",
failed: false,
mapStarCount: undefined,
leftHand: {
SaberA: {
averageCut: [15.0],
averagePreSwing: [70.0],
averagePostSwing: [30.0],
},
rightHand: {
SaberB: {
averageCut: [15.0],
averagePreSwing: [70.0],
averagePostSwing: [30.0],
@ -342,53 +342,26 @@ export default class Overlay extends Component {
noteFullyCut: (data) => {
const { noteCut } = data;
// Left Saber
if (noteCut.saberType === "SaberA") {
const data = this.state.leftHand;
if (data.averageCut.includes(15) && data.averageCut.length === 1) {
data.averageCut = [];
const cutData = this.state[noteCut.saberType];
if (cutData.averageCut.includes(15) && cutData.averageCut.length === 1) {
cutData.averageCut = [];
}
if (
data.averagePreSwing.includes(70) &&
data.averagePreSwing.length === 1
cutData.averagePreSwing.includes(70) &&
cutData.averagePreSwing.length === 1
) {
data.averagePreSwing = [];
cutData.averagePreSwing = [];
}
if (
data.averagePostSwing.includes(30) &&
data.averagePostSwing.length === 1
cutData.averagePostSwing.includes(30) &&
cutData.averagePostSwing.length === 1
) {
data.averagePostSwing = [];
}
data.averagePreSwing.push(noteCut.beforeSwingRating * 70);
data.averagePostSwing.push(noteCut.afterSwingRating * 30);
data.averageCut.push(noteCut.cutDistanceScore);
this.setState({ leftHand: data });
}
// Left Saber
if (noteCut.saberType === "SaberB") {
const data = this.state.rightHand;
if (data.averageCut.includes(15) && data.averageCut.length === 1) {
data.averageCut = [];
}
if (
data.averagePreSwing.includes(70) &&
data.averagePreSwing.length === 1
) {
data.averagePreSwing = [];
}
if (
data.averagePostSwing.includes(30) &&
data.averagePostSwing.length === 1
) {
data.averagePostSwing = [];
}
data.averagePreSwing.push(noteCut.beforeSwingRating * 70);
data.averagePostSwing.push(noteCut.afterSwingRating * 30);
data.averageCut.push(noteCut.cutDistanceScore);
this.setState({ rightHand: data });
cutData.averagePostSwing = [];
}
cutData.averagePreSwing.push(noteCut.beforeCutScore);
cutData.averagePostSwing.push(noteCut.afterCutScore);
cutData.averageCut.push(noteCut.cutDistanceScore);
this.setState({ [noteCut.saberType]: cutData });
},
songStart: (data) => {
console.log("Going into level, resetting data.");

@ -44,14 +44,14 @@ export default class ScoreStats extends Component {
<p className={styles.scoreStatsAverageCut}>Average Cut</p>
<div className={styles.scoreStatsHands}>
<div className={styles.scoreStatsLeft}>
<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>
<p>{this.getAverage(data.SaberA.averagePreSwing).toFixed(2)}</p>
<p>{this.getAverage(data.SaberA.averagePostSwing).toFixed(2)}</p>
<p>{this.getAverage(data.SaberA.averageCut).toFixed(2)}</p>
</div>
<div className={styles.scoreStatsRight}>
<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>
<p>{this.getAverage(data.SaberB.averagePreSwing).toFixed(2)}</p>
<p>{this.getAverage(data.SaberB.averagePostSwing).toFixed(2)}</p>
<p>{this.getAverage(data.SaberB.averageCut).toFixed(2)}</p>
</div>
</div>
</div>