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%", percentage: "100.00%",
failed: false, failed: false,
mapStarCount: undefined, mapStarCount: undefined,
leftHand: { SaberA: {
averageCut: [15.0], averageCut: [15.0],
averagePreSwing: [70.0], averagePreSwing: [70.0],
averagePostSwing: [30.0], averagePostSwing: [30.0],
}, },
rightHand: { SaberB: {
averageCut: [15.0], averageCut: [15.0],
averagePreSwing: [70.0], averagePreSwing: [70.0],
averagePostSwing: [30.0], averagePostSwing: [30.0],
@ -342,53 +342,26 @@ export default class Overlay extends Component {
noteFullyCut: (data) => { noteFullyCut: (data) => {
const { noteCut } = data; const { noteCut } = data;
// Left Saber const cutData = this.state[noteCut.saberType];
if (noteCut.saberType === "SaberA") { if (cutData.averageCut.includes(15) && cutData.averageCut.length === 1) {
const data = this.state.leftHand; cutData.averageCut = [];
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({ leftHand: data });
} }
if (
// Left Saber cutData.averagePreSwing.includes(70) &&
if (noteCut.saberType === "SaberB") { cutData.averagePreSwing.length === 1
const data = this.state.rightHand; ) {
if (data.averageCut.includes(15) && data.averageCut.length === 1) { cutData.averagePreSwing = [];
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 });
} }
if (
cutData.averagePostSwing.includes(30) &&
cutData.averagePostSwing.length === 1
) {
cutData.averagePostSwing = [];
}
cutData.averagePreSwing.push(noteCut.beforeCutScore);
cutData.averagePostSwing.push(noteCut.afterCutScore);
cutData.averageCut.push(noteCut.cutDistanceScore);
this.setState({ [noteCut.saberType]: cutData });
}, },
songStart: (data) => { songStart: (data) => {
console.log("Going into level, resetting 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> <p className={styles.scoreStatsAverageCut}>Average Cut</p>
<div className={styles.scoreStatsHands}> <div className={styles.scoreStatsHands}>
<div className={styles.scoreStatsLeft}> <div className={styles.scoreStatsLeft}>
<p>{this.getAverage(data.leftHand.averagePreSwing).toFixed(2)}</p> <p>{this.getAverage(data.SaberA.averagePreSwing).toFixed(2)}</p>
<p>{this.getAverage(data.leftHand.averagePostSwing).toFixed(2)}</p> <p>{this.getAverage(data.SaberA.averagePostSwing).toFixed(2)}</p>
<p>{this.getAverage(data.leftHand.averageCut).toFixed(2)}</p> <p>{this.getAverage(data.SaberA.averageCut).toFixed(2)}</p>
</div> </div>
<div className={styles.scoreStatsRight}> <div className={styles.scoreStatsRight}>
<p>{this.getAverage(data.rightHand.averagePreSwing).toFixed(2)}</p> <p>{this.getAverage(data.SaberB.averagePreSwing).toFixed(2)}</p>
<p>{this.getAverage(data.rightHand.averagePostSwing).toFixed(2)}</p> <p>{this.getAverage(data.SaberB.averagePostSwing).toFixed(2)}</p>
<p>{this.getAverage(data.rightHand.averageCut).toFixed(2)}</p> <p>{this.getAverage(data.SaberB.averageCut).toFixed(2)}</p>
</div> </div>
</div> </div>
</div> </div>