mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-05 13:28:08 +03:00
feat: just a bunch of cleanup
- no deduping, ui improvements, general fixups
This commit is contained in:
@@ -129,6 +129,10 @@ function SessionScoreStatBreakdown({
|
||||
Record<Grades[IDStrings], { score: ScoreDocument; scoreInfo: SessionScoreInfo }[]>
|
||||
> = {};
|
||||
|
||||
// dedupe grades/lamps for repeat plays
|
||||
const isBestGradeThisSession = new Map();
|
||||
const isBestLampThisSession = new Map();
|
||||
|
||||
for (const scoreInfo of sessionData.session.scoreInfo) {
|
||||
const score = scoreMap.get(scoreInfo.scoreID);
|
||||
|
||||
@@ -139,15 +143,51 @@ function SessionScoreStatBreakdown({
|
||||
continue;
|
||||
}
|
||||
|
||||
const g = isBestGradeThisSession.get(score.chartID);
|
||||
const l = isBestLampThisSession.get(score.chartID);
|
||||
|
||||
// if we haven't saw this chart before
|
||||
// or the score we have saw for this chart before had a worse grade
|
||||
if (!g || (g.scoreData.gradeIndex && g < score.scoreData.gradeIndex)) {
|
||||
isBestGradeThisSession.set(score.chartID, score);
|
||||
}
|
||||
|
||||
// same but for lamp
|
||||
if (!l || (l.scoreData.lampIndex && l < score.scoreData.lampIndex)) {
|
||||
isBestLampThisSession.set(score.chartID, score);
|
||||
}
|
||||
}
|
||||
|
||||
for (const scoreInfo of sessionData.session.scoreInfo) {
|
||||
const score = scoreMap.get(scoreInfo.scoreID);
|
||||
|
||||
if (!score) {
|
||||
console.error(
|
||||
`Session score info contains scoreID ${scoreInfo.scoreID}, but no score exists?`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
const wasBestLamp = isBestLampThisSession.get(score.chartID)?.scoreID === score.scoreID;
|
||||
const wasBestGrade =
|
||||
isBestGradeThisSession.get(score.chartID)?.scoreID === score.scoreID;
|
||||
|
||||
if (scoreInfo.isNewScore) {
|
||||
PartialArrayRecordAssign(newLamps, score.scoreData.lamp, { score, scoreInfo });
|
||||
PartialArrayRecordAssign(newGrades, score.scoreData.grade, { score, scoreInfo });
|
||||
if (wasBestLamp) {
|
||||
PartialArrayRecordAssign(newLamps, score.scoreData.lamp, { score, scoreInfo });
|
||||
}
|
||||
if (wasBestGrade) {
|
||||
PartialArrayRecordAssign(newGrades, score.scoreData.grade, {
|
||||
score,
|
||||
scoreInfo,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (scoreInfo.lampDelta > 0) {
|
||||
if (scoreInfo.lampDelta > 0 && wasBestLamp) {
|
||||
PartialArrayRecordAssign(newLamps, score.scoreData.lamp, { score, scoreInfo });
|
||||
}
|
||||
|
||||
if (scoreInfo.gradeDelta > 0) {
|
||||
if (scoreInfo.gradeDelta > 0 && wasBestLamp) {
|
||||
PartialArrayRecordAssign(newGrades, score.scoreData.grade, {
|
||||
score,
|
||||
scoreInfo,
|
||||
|
||||
Reference in New Issue
Block a user