Skip to content

Commit

Permalink
Merge pull request ppy#227 from MaxOhn/refactor-max-combo
Browse files Browse the repository at this point in the history
Refactor `GetMaxCombo`
  • Loading branch information
stanriders authored Oct 27, 2024
2 parents 156867c + 7686a41 commit ef80ec6
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 16 deletions.
5 changes: 1 addition & 4 deletions PerformanceCalculator/Simulate/CatchSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ public class CatchSimulateCommand : SimulateCommand

public override Ruleset Ruleset => new CatchRuleset();

protected override int GetMaxCombo(IBeatmap beatmap) => beatmap.HitObjects.Count(h => h is Fruit)
+ beatmap.HitObjects.OfType<JuiceStream>().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet));

protected override Dictionary<HitResult, int> GenerateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood)
{
var maxCombo = GetMaxCombo(beatmap);
var maxCombo = beatmap.GetMaxCombo();
int maxTinyDroplets = beatmap.HitObjects.OfType<JuiceStream>().Sum(s => s.NestedHitObjects.OfType<TinyDroplet>().Count());
int maxDroplets = beatmap.HitObjects.OfType<JuiceStream>().Sum(s => s.NestedHitObjects.OfType<Droplet>().Count()) - maxTinyDroplets;
int maxFruits = beatmap.HitObjects.Sum(h => h is Fruit ? 1 : (h as JuiceStream)?.NestedHitObjects.Count(n => n is Fruit) ?? 0);
Expand Down
2 changes: 0 additions & 2 deletions PerformanceCalculator/Simulate/ManiaSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class ManiaSimulateCommand : SimulateCommand

public override Ruleset Ruleset => new ManiaRuleset();

protected override int GetMaxCombo(IBeatmap beatmap) => 0;

protected override Dictionary<HitResult, int> GenerateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood)
{
// One judgement per normal note. Two judgements per hold note (head + tail).
Expand Down
2 changes: 0 additions & 2 deletions PerformanceCalculator/Simulate/OsuSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public class OsuSimulateCommand : SimulateCommand

public override Ruleset Ruleset => new OsuRuleset();

protected override int GetMaxCombo(IBeatmap beatmap) => beatmap.GetMaxCombo();

protected override Dictionary<HitResult, int> GenerateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood)
{
int countGreat;
Expand Down
4 changes: 1 addition & 3 deletions PerformanceCalculator/Simulate/SimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void Execute()
var mods = ParseMods(ruleset, Mods, ModOptions);
var beatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

var beatmapMaxCombo = GetMaxCombo(beatmap);
var beatmapMaxCombo = beatmap.GetMaxCombo();
var statistics = GenerateHitResults(Accuracy / 100, beatmap, Misses, Mehs, Goods);
var scoreInfo = new ScoreInfo(beatmap.BeatmapInfo, ruleset.RulesetInfo)
{
Expand All @@ -83,8 +83,6 @@ public override void Execute()
OutputPerformance(scoreInfo, performanceAttributes, difficultyAttributes);
}

protected abstract int GetMaxCombo(IBeatmap beatmap);

protected abstract Dictionary<HitResult, int> GenerateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood);

protected virtual double GetAccuracy(Dictionary<HitResult, int> statistics) => 0;
Expand Down
6 changes: 1 addition & 5 deletions PerformanceCalculator/Simulate/TaikoSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using McMaster.Extensions.CommandLineUtils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Taiko.Objects;

namespace PerformanceCalculator.Simulate
{
Expand All @@ -31,11 +29,9 @@ public class TaikoSimulateCommand : SimulateCommand

public override Ruleset Ruleset => new TaikoRuleset();

protected override int GetMaxCombo(IBeatmap beatmap) => beatmap.HitObjects.OfType<Hit>().Count();

protected override Dictionary<HitResult, int> GenerateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood)
{
var totalResultCount = GetMaxCombo(beatmap);
var totalResultCount = beatmap.GetMaxCombo();

int countGreat;

Expand Down

0 comments on commit ef80ec6

Please sign in to comment.