From 0f13ccc0eff7710e079e23abb504762cc0bad595 Mon Sep 17 00:00:00 2001 From: Samuel Cattini-Schultz Date: Tue, 21 Nov 2023 17:35:57 +1100 Subject: [PATCH] Fix missing SliderCount in serialisation --- Difficalcy.Catch/Services/CatchCalculatorService.cs | 5 +---- Difficalcy.Mania/Services/ManiaCalculatorService.cs | 5 +---- Difficalcy.Osu/Services/OsuCalculatorService.cs | 3 ++- Difficalcy.Taiko/Services/TaikoCalculatorService.cs | 5 +---- Difficalcy/DifficalcyStartup.cs | 1 - 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Difficalcy.Catch/Services/CatchCalculatorService.cs b/Difficalcy.Catch/Services/CatchCalculatorService.cs index 9fee4a3..d346b46 100644 --- a/Difficalcy.Catch/Services/CatchCalculatorService.cs +++ b/Difficalcy.Catch/Services/CatchCalculatorService.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Text.Json; using System.Threading.Tasks; using Difficalcy.Catch.Models; using Difficalcy.Models; using Difficalcy.Services; -using Microsoft.Extensions.Configuration; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Catch; @@ -60,7 +57,7 @@ protected override (object, string) CalculateDifficultyAttributes(CatchScore sco var difficultyCalculator = CatchRuleset.CreateDifficultyCalculator(workingBeatmap); var difficultyAttributes = difficultyCalculator.Calculate(mods) as CatchDifficultyAttributes; - // Serialising anonymous object with same names because Mods and Skills can't be serialised + // Serialising anonymous object with same names because some properties can't be serialised, and the built-in JsonProperty fields aren't on all required fields return (difficultyAttributes, JsonSerializer.Serialize(new { StarRating = difficultyAttributes.StarRating, diff --git a/Difficalcy.Mania/Services/ManiaCalculatorService.cs b/Difficalcy.Mania/Services/ManiaCalculatorService.cs index a4c8585..59cebc8 100644 --- a/Difficalcy.Mania/Services/ManiaCalculatorService.cs +++ b/Difficalcy.Mania/Services/ManiaCalculatorService.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Text.Json; using System.Threading.Tasks; using Difficalcy.Mania.Models; using Difficalcy.Models; using Difficalcy.Services; -using Microsoft.Extensions.Configuration; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Mania; using osu.Game.Rulesets.Mania.Difficulty; @@ -59,7 +56,7 @@ protected override (object, string) CalculateDifficultyAttributes(ManiaScore sco var difficultyCalculator = ManiaRuleset.CreateDifficultyCalculator(workingBeatmap); var difficultyAttributes = difficultyCalculator.Calculate(mods) as ManiaDifficultyAttributes; - // Serialising anonymous object with same names because Mods and Skills can't be serialised + // Serialising anonymous object with same names because some properties can't be serialised, and the built-in JsonProperty fields aren't on all required fields return (difficultyAttributes, JsonSerializer.Serialize(new { StarRating = difficultyAttributes.StarRating, diff --git a/Difficalcy.Osu/Services/OsuCalculatorService.cs b/Difficalcy.Osu/Services/OsuCalculatorService.cs index 0d8712c..df5495a 100644 --- a/Difficalcy.Osu/Services/OsuCalculatorService.cs +++ b/Difficalcy.Osu/Services/OsuCalculatorService.cs @@ -56,7 +56,7 @@ protected override (object, string) CalculateDifficultyAttributes(OsuScore score var difficultyCalculator = OsuRuleset.CreateDifficultyCalculator(workingBeatmap); var difficultyAttributes = difficultyCalculator.Calculate(mods) as OsuDifficultyAttributes; - // Serialising anonymous object with same names because Mods and Skills can't be serialised + // Serialising anonymous object with same names because some properties can't be serialised, and the built-in JsonProperty fields aren't on all required fields return (difficultyAttributes, JsonSerializer.Serialize(new { StarRating = difficultyAttributes.StarRating, @@ -68,6 +68,7 @@ protected override (object, string) CalculateDifficultyAttributes(OsuScore score OverallDifficulty = difficultyAttributes.OverallDifficulty, DrainRate = difficultyAttributes.DrainRate, HitCircleCount = difficultyAttributes.HitCircleCount, + SliderCount = difficultyAttributes.SliderCount, SpinnerCount = difficultyAttributes.SpinnerCount })); } diff --git a/Difficalcy.Taiko/Services/TaikoCalculatorService.cs b/Difficalcy.Taiko/Services/TaikoCalculatorService.cs index a76b362..eb493c8 100644 --- a/Difficalcy.Taiko/Services/TaikoCalculatorService.cs +++ b/Difficalcy.Taiko/Services/TaikoCalculatorService.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Text.Json; using System.Threading.Tasks; using Difficalcy.Models; using Difficalcy.Services; using Difficalcy.Taiko.Models; -using Microsoft.Extensions.Configuration; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Taiko; @@ -59,7 +56,7 @@ protected override (object, string) CalculateDifficultyAttributes(TaikoScore sco var difficultyCalculator = TaikoRuleset.CreateDifficultyCalculator(workingBeatmap); var difficultyAttributes = difficultyCalculator.Calculate(mods) as TaikoDifficultyAttributes; - // Serialising anonymous object with same names because Mods and Skills can't be serialised + // Serialising anonymous object with same names because some properties can't be serialised, and the built-in JsonProperty fields aren't on all required fields return (difficultyAttributes, JsonSerializer.Serialize(new { StarRating = difficultyAttributes.StarRating, diff --git a/Difficalcy/DifficalcyStartup.cs b/Difficalcy/DifficalcyStartup.cs index 5b8a0a3..2a543a8 100644 --- a/Difficalcy/DifficalcyStartup.cs +++ b/Difficalcy/DifficalcyStartup.cs @@ -1,4 +1,3 @@ -using System; using Difficalcy.Services; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting;