Skip to content

Commit

Permalink
Category implementation, untested
Browse files Browse the repository at this point in the history
  • Loading branch information
Futuremappermydud committed Dec 14, 2023
1 parent 3fc6e81 commit 07bea4d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions BSChallenger.Server/Jobs/ScanProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class ScanProcess

private List<BeatLeaderScore> CurrentScanningScores { get; set; }

string[] ParseCategories(Level level)
{
return level.RequiredCategoryData.Split(",");
}

public void ScanUser(User user, Ranking ranking, List<BeatLeaderScore> scores)
{
CurrentScanningScores = scores;
Expand All @@ -35,13 +40,26 @@ public void ScanUser(User user, Ranking ranking, List<BeatLeaderScore> scores)
if(ScoresToCheck.Count > 0)
{
var anyPassed = true;
List<string> categoriesPassed = new();
foreach(var score in ScoresToCheck)
{
var passed = ScanMap(score.map, score.score, level);
if(passed)
{
var categoryFeature = score.map.Features.FirstOrDefault(x => x.Type == "category");
if (categoryFeature != null && !categoriesPassed.Contains(categoryFeature.Data))
{
categoriesPassed.Add(categoryFeature.Data);
}
}
scanHistoryScores.Add(new ScoreData(score.map, passed, score.score.ModifiedScore, (float)score.score.Accuracy, score.score.Modifiers));
anyPassed &= passed;
}
if(anyPassed)
if (level.RequiredCategoryData.StartsWith("min:") && int.TryParse(level.RequiredCategoryData.Replace("min:", ""), out int minimumCategories) && minimumCategories > categoriesPassed.Count)
{
anyPassed = false;
}
if (anyPassed)
{
latestLevelPassed = level;
}
Expand All @@ -62,7 +80,7 @@ public void ScanUser(User user, Ranking ranking, List<BeatLeaderScore> scores)
private static void SetUserLevelForRanking(User user, Level level, Ranking ranking)
{
var existing = user.UserLevels.FirstOrDefault(x => x.RankingId == ranking.Identifier);
if(existing == null)
if (existing == null)
{
user.UserLevels.Add(new UserLevel(level.LevelNumber, ranking.Identifier));
}
Expand Down

0 comments on commit 07bea4d

Please sign in to comment.