Skip to content

Commit

Permalink
Fixing hard chart detection
Browse files Browse the repository at this point in the history
  • Loading branch information
afska committed Sep 2, 2020
1 parent 4c51c83 commit 0726ab6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/importer/src/importers/integrity/completeMissingData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -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(
Expand Down

0 comments on commit 0726ab6

Please sign in to comment.