From 0726ab6eac5afaa57350fdd6888306c95608efb6 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Tue, 1 Sep 2020 23:06:32 -0300 Subject: [PATCH] Fixing hard chart detection --- .../importers/integrity/completeMissingData.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/importer/src/importers/integrity/completeMissingData.js b/scripts/importer/src/importers/integrity/completeMissingData.js index 30384b9d..bffa1712 100644 --- a/scripts/importer/src/importers/integrity/completeMissingData.js +++ b/scripts/importer/src/importers/integrity/completeMissingData.js @@ -101,6 +101,10 @@ const autoSetDifficulty = (charts, difficultyName) => { const numericDifficultyCharts = charts.filter( (it) => it.header.difficulty === "NUMERIC" ); + const sortedNumericDifficultyCharts = _.orderBy( + charts, + (it) => it.header.level + ); let chart = null; for (let level of HEURISTICS[difficultyName]) { @@ -112,10 +116,17 @@ const autoSetDifficulty = (charts, difficultyName) => { if (candidate) chart = getBestChartBetween(candidate, chart); } - if (!chart && (difficultyName === "CRAZY" || difficultyName === "HARD")) - chart = _.last(numericDifficultyCharts); + if (!chart && difficultyName === "CRAZY") + chart = _.last(sortedNumericDifficultyCharts); + if (!chart && difficultyName === "HARD") { + const crazyChart = _.find(charts, (it) => it.header.difficulty === "CRAZY"); + chart = _.findLast( + sortedNumericDifficultyCharts, + (it) => it.header.level < crazyChart.header.level + ); + } if (!chart && difficultyName === "NORMAL") - chart = _.first(numericDifficultyCharts); + chart = _.first(sortedNumericDifficultyCharts); if (!chart) throw new Error(