Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply adjustments for struct attributes #233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PerformanceCalculator/Difficulty/DifficultyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private class Result
public List<APIMod> Mods { get; set; }

[JsonProperty("attributes")]
public DifficultyAttributes Attributes { get; set; }
public IDifficultyAttributes Attributes { get; set; }
}
}
}
21 changes: 0 additions & 21 deletions PerformanceCalculator/LegacyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,5 @@ public static string GetRulesetShortNameFromId(int id)
return "mania";
}
}

public static DifficultyAttributes CreateDifficultyAttributes(int legacyId)
{
switch (legacyId)
{
case 0:
return new OsuDifficultyAttributes();

case 1:
return new TaikoDifficultyAttributes();

case 2:
return new CatchDifficultyAttributes();

case 3:
return new ManiaDifficultyAttributes();

default:
throw new ArgumentException($"Invalid ruleset ID: {legacyId}", nameof(legacyId));
}
}
Comment on lines -62 to -81
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this method as it is unused

}
}
10 changes: 5 additions & 5 deletions PerformanceCalculator/Performance/ScorePerformanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Execute()
var workingBeatmap = ProcessorWorkingBeatmap.FromFileOrId(apiScore.BeatmapID.ToString());
var score = CreateScore(apiScore, ruleset, apiBeatmap, workingBeatmap);

DifficultyAttributes attributes;
IDifficultyAttributes attributes;

if (OnlineAttributes)
{
Expand Down Expand Up @@ -78,7 +78,7 @@ protected virtual ScoreInfo CreateScore(SoloScoreInfo apiScore, Ruleset ruleset,
return score;
}

private DifficultyAttributes queryApiAttributes(int beatmapId, int rulesetId, LegacyMods mods)
private IDifficultyAttributes queryApiAttributes(int beatmapId, int rulesetId, LegacyMods mods)
{
Dictionary<string, string> parameters = new Dictionary<string, string>
{
Expand All @@ -105,8 +105,8 @@ private DifficultyAttributes queryApiAttributes(int beatmapId, int rulesetId, Le
throw new ArgumentOutOfRangeException(nameof(rulesetId));
}

DifficultyAttributes getMergedAttributes<TAttributes>(APIBeatmap apiBeatmap)
where TAttributes : DifficultyAttributes, new()
IDifficultyAttributes getMergedAttributes<TAttributes>(APIBeatmap apiBeatmap)
where TAttributes : IDifficultyAttributes, new()
{
// the osu-web endpoint queries osu-beatmap-difficulty-cache, which in turn does not return the full set of attributes -
// it skips ones that are already present on `APIBeatmap`
Expand Down Expand Up @@ -165,7 +165,7 @@ static LegacyMods maskRelevantMods(LegacyMods mods, bool isConvertedBeatmap, int

[JsonObject(MemberSerialization.OptIn)]
private class AttributesResponse<T>
where T : DifficultyAttributes
where T : IDifficultyAttributes
{
[JsonProperty("attributes")]
public T Attributes { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions PerformanceCalculator/ProcessorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public virtual void OnExecute(CommandLineApplication app, IConsole console)
Execute();
}

public void OutputPerformance(ScoreInfo score, PerformanceAttributes performanceAttributes, DifficultyAttributes difficultyAttributes)
public void OutputPerformance(ScoreInfo score, IPerformanceAttributes performanceAttributes, IDifficultyAttributes difficultyAttributes)
{
var result = new Result
{
Expand Down Expand Up @@ -170,10 +170,10 @@ private class Result
public ScoreStatistics Score { get; set; }

[JsonProperty("performance_attributes")]
public PerformanceAttributes PerformanceAttributes { get; set; }
public IPerformanceAttributes PerformanceAttributes { get; set; }

[JsonProperty("difficulty_attributes")]
public DifficultyAttributes DifficultyAttributes { get; set; }
public IDifficultyAttributes DifficultyAttributes { get; set; }
}

/// <summary>
Expand Down
Loading