Skip to content

Commit de647d4

Browse files
committed
Include Ruleset ID in /difficulty
1 parent 7e329d4 commit de647d4

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

PerformanceServer/BeatmapDifficultyController.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,19 @@ public async Task<ActionResult<DifficultyAttributes>> CalculateDifficulty([FromB
5151
}
5252
}
5353

54-
Ruleset ruleset = Helper.GetRuleset(body.RulesetId ?? workingBeatmap.BeatmapInfo.Ruleset.OnlineID);
54+
int rulesetId = body.RulesetId ?? workingBeatmap.BeatmapInfo.Ruleset.OnlineID;
55+
Ruleset ruleset = Helper.GetRuleset(rulesetId);
5556
Mod[] mods = body.Mods.Select(m => m.ToMod(ruleset)).ToArray();
5657
DifficultyAttributes? difficultyAttributes =
5758
ruleset.CreateDifficultyCalculator(workingBeatmap).Calculate(mods);
5859

59-
return Ok(difficultyAttributes);
60+
Dictionary<string, object>? attr =
61+
JsonConvert.DeserializeObject<Dictionary<string, object>>(
62+
JsonConvert.SerializeObject(difficultyAttributes));
63+
if (attr != null)
64+
attr["ruleset_id"] = rulesetId;
65+
66+
return attr != null ? Ok(attr) : BadRequest("Failed to calculate difficulty.");
6067
}
6168
}
6269
}

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Minimal example:
8888
}
8989
```
9090

91-
Successful Response: `200 OK` with a JSON `PerformanceAttributes` object including (fields differ by ruleset):
91+
Successful Response: `200 OK` with a JSON `PerformanceAttributes` object with `ruleset_id` including (fields differ by ruleset):
9292
- `total` (float) Total pp value.
9393
- Component breakdown fields (aim, speed, flashlight, accuracy, strain, etc.)
9494
- Embedded `DifficultyAttributes` subset depending on version
@@ -123,7 +123,9 @@ Advanced mods with settings (e.g., DT with speed change) are not yet surfaced he
123123
- Providing a `checksum` with a cached map triggers integrity verification (MD5). A mismatch forces redownload.
124124

125125
## Troubleshooting
126-
| Issue | Cause | Resolution |
127-
|--------------------|------------------------------------|----------------------------------------------------------|
128-
| 503 on fetch | Beatmap not reachable | Verify ID exists, network, or site availability |
129-
| 400 on performance | Invalid statistics / internal null | Ensure ruleset matches beatmap & stats not contradictory |
126+
| Issue | Cause | Resolution |
127+
|--------------------|------------------------------------|------------------------------------------------------------------------|
128+
| 503 on fetch | Beatmap not reachable | Verify ID exists, network, or site availability |
129+
| 400 on performance | Invalid statistics / internal null | Ensure ruleset matches beatmap & stats not contradictory |
130+
| 400 on difficulty | Invalid beatmap / ruleset | Ensure beatmap is valid & beatmap can be convert into specific ruleset |
131+

0 commit comments

Comments
 (0)