Skip to content

Commit

Permalink
Improve single leaderboard requests
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Jan 16, 2025
1 parent 9dbdf3d commit 129b269
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Src/ManiaAPI.XmlRpc/MP4/CampaignLeaderboardType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ManiaAPI.XmlRpc.MP4;

public enum CampaignLeaderboardType
{
SkillPoint,
MultiAsyncLevel
}
9 changes: 5 additions & 4 deletions Src/ManiaAPI.XmlRpc/MP4/MasterServerMP4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ protected async Task<string> SendAsync(string titleId, string requestName, strin

public async Task<IEnumerable<LeaderboardItem>> GetCampaignLeaderBoardAsync(
string titleId,
string? campaignId = null,
int count = 10,
int offset = 0,
string zone = "World",
CampaignLeaderboardType type = CampaignLeaderboardType.SkillPoint,
CancellationToken cancellationToken = default)
{
const string RequestName = "GetCampaignLeaderBoard";
var responseStr = await SendAsync(titleId, RequestName, @$"
<f>{offset}</f>
<n>{count}</n>
<c>{titleId}</c>
<c>{campaignId ?? titleId}</c>
<m></m>
<t></t>
<z>{zone}</z>
<s>SkillPoint</s>", cancellationToken);
<s>{type}</s>", cancellationToken);
return ProcessResponseResult(RequestName, responseStr, ReadLeaderboardItems);
}

Expand All @@ -57,14 +59,13 @@ public async Task<IEnumerable<LeaderboardItem>> GetMapLeaderBoardAsync(
CancellationToken cancellationToken = default)
{
const string RequestName = "GetMapLeaderBoard";

var responseStr = await SendAsync(titleId, RequestName, @$"
<m>{mapUid}</m>
<n>{count}</n>
<f>{offset}</f>
<z>{zone}</z>
<c></c>
<t></t>
<t>{context}</t>
<s>MapRecord</s>", cancellationToken);
return ProcessResponseResult(RequestName, responseStr, ReadLeaderboardItems);
}
Expand Down

0 comments on commit 129b269

Please sign in to comment.