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

Read scoring attributes from the new table #155

Merged
merged 2 commits into from
Sep 29, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<ItemGroup>
<PackageReference Include="DeepEqual" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
Expand Down Expand Up @@ -570,42 +569,20 @@ private async Task<ScoreInfo> createReferenceScore(Ruleset ruleset, HighScore hi
return scoreInfo;
}

const int legacy_accuracy_score = 23;
const int legacy_combo_score = 25;
const int legacy_bonus_score_ratio = 27;

if (!dbAttributes.ContainsKey(legacy_accuracy_score) || !dbAttributes.ContainsKey(legacy_combo_score) || !dbAttributes.ContainsKey(legacy_bonus_score_ratio))
{
await Console.Error.WriteLineAsync($"{highScore.score_id}: Could not find legacy scoring values in the difficulty attributes of beatmap {highScore.beatmap_id}.");
return scoreInfo;
}

#pragma warning disable CS0618
// Pad the maximum combo.
if ((int)maxComboAttribute.value > maxComboFromStatistics)
scoreInfo.MaximumStatistics[HitResult.LegacyComboIncrease] = (int)maxComboAttribute.value - maxComboFromStatistics;
#pragma warning restore CS0618

int maximumLegacyAccuracyScore = (int)dbAttributes[legacy_accuracy_score].value;
int maximumLegacyComboScore = (int)dbAttributes[legacy_combo_score].value;
double maximumLegacyBonusRatio = dbAttributes[legacy_bonus_score_ratio].value;

// Although the combo-multiplied portion is stored into difficulty attributes, attributes are only present for mod combinations that affect difficulty.
// For example, an incoming highscore may be +HDHR, but only difficulty attributes for +HR exist in the database.
// To handle this case, the combo-multiplied portion is readjusted with the new mod multiplier.
if (difficultyMods != highScore.enabled_mods)
{
double difficultyAdjustmentModMultiplier = ruleset.ConvertFromLegacyMods((LegacyMods)difficultyMods).Select(m => m.ScoreMultiplier).Aggregate(1.0, (c, n) => c * n);
double modMultiplier = scoreInfo.Mods.Select(m => m.ScoreMultiplier).Aggregate(1.0, (c, n) => c * n);
maximumLegacyComboScore = (int)Math.Round(maximumLegacyComboScore * modMultiplier / difficultyAdjustmentModMultiplier);
}
BeatmapScoringAttributes scoreAttributes = await connection.QuerySingleAsync<BeatmapScoringAttributes>(
"SELECT * FROM osu_beatmap_scoring_attribs WHERE beatmap_id = @BeatmapId AND mode = @RulesetId", new
{
BeatmapId = highScore.beatmap_id,
RulesetId = ruleset.RulesetInfo.OnlineID
}, transaction);

scoreInfo.TotalScore = StandardisedScoreMigrationTools.ConvertFromLegacyTotalScore(scoreInfo, new DifficultyAttributes
{
LegacyAccuracyScore = maximumLegacyAccuracyScore,
LegacyComboScore = maximumLegacyComboScore,
LegacyBonusScoreRatio = maximumLegacyBonusRatio
});
scoreInfo.TotalScore = StandardisedScoreMigrationTools.ConvertFromLegacyTotalScore(scoreInfo, scoreAttributes.ToAttributes());

int baseScore = scoreInfo.Statistics.Where(kvp => kvp.Key.AffectsAccuracy()).Sum(kvp => kvp.Value * Judgement.ToNumericResult(kvp.Key));
int maxBaseScore = scoreInfo.MaximumStatistics.Where(kvp => kvp.Key.AffectsAccuracy()).Sum(kvp => kvp.Value * Judgement.ToNumericResult(kvp.Key));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Diagnostics.CodeAnalysis;
using Dapper.Contrib.Extensions;
using osu.Game.Rulesets.Scoring.Legacy;

namespace osu.Server.Queues.ScoreStatisticsProcessor.Models
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
[Serializable]
[Table("osu_beatmap_scoring_attribs")]
public class BeatmapScoringAttributes
{
[ExplicitKey]
public uint beatmap_id { get; set; }

public ushort mode { get; set; }

public int legacy_accuracy_score { get; set; }

public long legacy_combo_score { get; set; }

public float legacy_bonus_score_ratio { get; set; }

public LegacyScoreAttributes ToAttributes() => new LegacyScoreAttributes
{
AccuracyScore = legacy_accuracy_score,
ComboScore = legacy_combo_score,
BonusScoreRatio = legacy_bonus_score_ratio
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Dapper" Version="2.0.151" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include="ppy.osu.Game" Version="2023.814.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.814.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.814.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.814.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.814.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
<PackageReference Include="ppy.osu.Game" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Server.OsuQueueProcessor" Version="2023.822.0" />
</ItemGroup>

Expand Down