Skip to content

Commit

Permalink
Merge pull request #218 from bdach/use-ranked-property
Browse files Browse the repository at this point in the history
Use reintroduced `IMod.Ranked` property from game to determine eligibility of score for pp
  • Loading branch information
peppy authored Feb 10, 2024
2 parents 5bb3f12 + 71c120a commit c3b8f03
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 75 deletions.
6 changes: 3 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2022.3.2",
"version": "2023.3.3",
"commands": [
"jb"
]
},
"nvika": {
"version": "2.2.0",
"version": "3.0.0",
"commands": [
"nvika"
]
Expand All @@ -21,4 +21,4 @@
]
}
}
}
}
19 changes: 6 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

# FIXME: Tools won't run in .NET 6.0 unless you install 3.1.x LTS side by side.
# https://itnext.io/how-to-support-multiple-net-sdks-in-github-actions-workflows-b988daa884e
- name: Install .NET 3.1.x LTS
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"
uses: actions/checkout@v3

- name: Install .NET 6.0.x
uses: actions/setup-dotnet@v1
- name: Install .NET 8.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
dotnet-version: "8.0.x"

- name: Restore Tools
run: dotnet tool restore
Expand Down Expand Up @@ -56,10 +49,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install .NET 6.0.x
- name: Install .NET 8.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"
dotnet-version: "8.0.x"

- name: Docker compose
run: docker compose up -d
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions osu.Server.Queues.ScoreStatisticsProcessor.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleInterfaceMemberAmbiguity/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleMultipleEnumeration/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PrivateVariableCanBeMadeReadonly/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002EGlobal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002ELocal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAnonymousTypePropertyName/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentDefaultValue/@EntryIndexedValue">HINT</s:String>
Expand All @@ -142,6 +144,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExplicitParamsArrayCreation/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantImmediateDelegateInvocation/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantLambdaSignatureParentheses/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantTypeDeclarationBody/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantTypeSpecificationInDefaultExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantLinebreak/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantSpace/@EntryIndexedValue">WARNING</s:String>
Expand Down
4 changes: 2 additions & 2 deletions osu.Server.Queues.ScoreStatisticsProcessor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
Expand All @@ -12,7 +12,7 @@ RUN dotnet publish -c Release -o out
RUN rm -rf ./out/runtimes ./out/osu.Game.Resources.dll

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:6.0
FROM mcr.microsoft.com/dotnet/runtime:8.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "osu.Server.Queues.ScoreStatisticsProcessor.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using MySqlConnector;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mania.Mods;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring;
using osu.Server.Queues.ScoreStatisticsProcessor.Helpers;
using osu.Server.Queues.ScoreStatisticsProcessor.Models;
Expand Down Expand Up @@ -199,56 +198,13 @@ Task<int> markNonRanked()
/// </summary>
public static bool AllModsValidForPerformance(SoloScoreInfo score, Mod[] mods)
{
foreach (var m in mods)
{
switch (m)
{
// Overrides for mods which would otherwise be allowed by the block below.
case ManiaModHardRock:
case ManiaModKey1:
case ManiaModKey2:
case ManiaModKey3:
case ManiaModKey10:
return false;

// The mods which are allowed.
case ModEasy:
case ModNoFail:
case ModSuddenDeath:
case ModPerfect:
case ModHardRock:
case ModHidden:
case ModFlashlight:
case ModMuted:
case ModNightcore:
case ModDoubleTime:
case ModDaycore:
case ModHalfTime:
// osu!-specific:
case OsuModSpunOut:
case OsuModTouchDevice:
// mania-specific:
case ManiaKeyMod:
case ManiaModMirror:
break;

// Classic mod is only allowed on legacy scores.
case ModClassic:
if (!score.IsLegacyScore)
return false;

break;

// Any other mods not in the above list aren't allowed.
default:
return false;
}
IEnumerable<Mod> modsToCheck = mods;

if (!m.UsesDefaultConfiguration)
return false;
}
// Classic mod is only allowed on legacy scores.
if (score.IsLegacyScore)
modsToCheck = mods.Where(mod => mod is not ModClassic);

return true;
return modsToCheck.All(m => m.Ranked);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>osu.Server.Queues.ScoreStatisticsProcessor</RootNamespace>
<AssemblyName>osu.Server.Queues.ScoreStatisticsProcessor</AssemblyName>
Expand All @@ -12,11 +12,11 @@
<PackageReference Include="Dapper" Version="2.1.28" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
<PackageReference Include="ppy.osu.Game" Version="2024.124.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2024.124.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2024.124.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2024.124.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2024.124.0" />
<PackageReference Include="ppy.osu.Game" Version="2024.210.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2024.210.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2024.210.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2024.210.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2024.210.0" />
<PackageReference Include="ppy.osu.Server.OsuQueueProcessor" Version="2023.1207.0" />
</ItemGroup>

Expand Down

0 comments on commit c3b8f03

Please sign in to comment.