Skip to content

Commit

Permalink
Fix missing SliderCount in serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Syriiin committed Nov 21, 2023
1 parent be9fd7e commit 0f13ccc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
5 changes: 1 addition & 4 deletions Difficalcy.Catch/Services/CatchCalculatorService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions Difficalcy.Mania/Services/ManiaCalculatorService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion Difficalcy.Osu/Services/OsuCalculatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}));
}
Expand Down
5 changes: 1 addition & 4 deletions Difficalcy.Taiko/Services/TaikoCalculatorService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion Difficalcy/DifficalcyStartup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Difficalcy.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand Down

0 comments on commit 0f13ccc

Please sign in to comment.