From c002647108aafa2a3861c392c674eaaf8b1b7170 Mon Sep 17 00:00:00 2001 From: Liam <67254223+RealFascinated@users.noreply.github.com> Date: Tue, 25 Oct 2022 13:02:35 +0100 Subject: [PATCH] Hopefully fix cut values (thanks denpadokei) --- src/components/ScoreStats.js | 12 +++--- src/pages/overlay.js | 79 ++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/src/components/ScoreStats.js b/src/components/ScoreStats.js index 99b5dcd..59b2bd7 100644 --- a/src/components/ScoreStats.js +++ b/src/components/ScoreStats.js @@ -44,14 +44,14 @@ export default class ScoreStats extends Component {

Average Cut

-

{this.getAverage(data.SaberA.averagePreSwing).toFixed(2)}

-

{this.getAverage(data.SaberA.averagePostSwing).toFixed(2)}

-

{this.getAverage(data.SaberA.averageCut).toFixed(2)}

+

{data.SaberA.averagePreSwing.toFixed(2)}

+

{data.SaberA.averagePostSwing.toFixed(2)}

+

{data.SaberA.cutDistanceScore.toFixed(2)}

-

{this.getAverage(data.SaberB.averagePreSwing).toFixed(2)}

-

{this.getAverage(data.SaberB.averagePostSwing).toFixed(2)}

-

{this.getAverage(data.SaberB.averageCut).toFixed(2)}

+

{data.SaberB.averagePreSwing.toFixed(2)}

+

{data.SaberB.averagePostSwing.toFixed(2)}

+

{data.SaberB.cutDistanceScore.toFixed(2)}

diff --git a/src/pages/overlay.js b/src/pages/overlay.js index d92d853..8c491aa 100644 --- a/src/pages/overlay.js +++ b/src/pages/overlay.js @@ -15,6 +15,16 @@ export default class Overlay extends Component { constructor(props) { super(props); + this.cutData = []; + this.cutData.SaberA = { + count: [0, 0, 0], + totalScore: [0, 0, 0], + }; + this.cutData.SaberB = { + count: [0, 0, 0], + totalScore: [0, 0, 0], + }; + this._mounted = false; this.state = { hasError: false, @@ -41,14 +51,14 @@ export default class Overlay extends Component { failed: false, mapStarCount: undefined, SaberA: { - averageCut: [15.0], - averagePreSwing: [70.0], - averagePostSwing: [30.0], + cutDistanceScore: 0.0, + averagePreSwing: 0.0, + averagePostSwing: 0.0, }, SaberB: { - averageCut: [15.0], - averagePreSwing: [70.0], - averagePostSwing: [30.0], + cutDistanceScore: 0.0, + averagePreSwing: 0.0, + averagePostSwing: 0.0, }, }; this.setupTimer(); @@ -297,16 +307,25 @@ export default class Overlay extends Component { await this.updateData(this.state.id); }, 1000); // 1 second } + this.cutData = []; + this.cutData.SaberA = { + count: [0, 0, 0], + totalScore: [0, 0, 0], + }; + this.cutData.SaberB = { + count: [0, 0, 0], + totalScore: [0, 0, 0], + }; this.setState({ SaberA: { - averageCut: [15.0], - averagePreSwing: [70.0], - averagePostSwing: [30.0], + cutDistanceScore: 0.0, + averagePreSwing: 0.0, + averagePostSwing: 0.0, }, SaberB: { - averageCut: [15.0], - averagePreSwing: [70.0], - averagePostSwing: [30.0], + cutDistanceScore: 0.0, + averagePreSwing: 0.0, + averagePostSwing: 0.0, }, songInfo: undefined, beatSaverData: undefined, @@ -352,25 +371,25 @@ export default class Overlay extends Component { noteFullyCut: (data) => { const { noteCut } = data; + let beforeCutScore = 0.0; + let afterCutScore = 0.0; + let cutDistanceScore = 0.0; + + const cutDataSaber = this.cutData[noteCut.saberType]; + cutDataSaber.count[0]++; + cutDataSaber.count[1]++; + cutDataSaber.count[2]++; + cutDataSaber.totalScore[0] += noteCut.beforeCutScore; + cutDataSaber.totalScore[1] += noteCut.afterCutScore; + cutDataSaber.totalScore[2] += noteCut.cutDistanceScore; + beforeCutScore = cutDataSaber.totalScore[0] / cutDataSaber.count[0]; + afterCutScore = cutDataSaber.totalScore[1] / cutDataSaber.count[1]; + cutDistanceScore = cutDataSaber.totalScore[2] / cutDataSaber.count[2]; + const cutData = this.state[noteCut.saberType]; - if (cutData.averageCut.includes(15) && cutData.averageCut.length === 1) { - cutData.averageCut = []; - } - if ( - cutData.averagePreSwing.includes(70) && - cutData.averagePreSwing.length === 1 - ) { - cutData.averagePreSwing = []; - } - 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); + cutData.averagePreSwing = beforeCutScore; + cutData.averagePostSwing = afterCutScore; + cutData.cutDistanceScore = cutDistanceScore; this.setState({ [noteCut.saberType]: cutData }); }, songStart: (data) => {