Skip to content

Commit 24eeaa0

Browse files
committed
feat: Add conditional filtering support to score sheet rendering
Added conditional filtering functionality for Lxns and DivingFish data sources. Added a `condition` field in the request protocol, and modified the rendering service to accept and pass this parameter to the drawing layer, allowing the frontend to filter displayed score records based on specific conditions.
1 parent c1a922b commit 24eeaa0

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/Protos/kumabot.proto

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ message LxnsBestsRequest {
2020
string devToken = 1;
2121
google.protobuf.StringValue personalToken = 2;
2222
google.protobuf.UInt32Value qq = 3;
23-
repeated string tags = 4;
23+
google.protobuf.StringValue condition = 4;
24+
repeated string tags = 5;
2425
}
2526

2627
message DivingFishBestsRequest {
2728
uint32 qq = 1;
28-
sint32 frame = 2;
29-
sint32 plate = 3;
30-
sint32 icon = 4;
31-
repeated string tags = 5;
29+
google.protobuf.StringValue condition = 2;
30+
sint32 frame = 3;
31+
sint32 plate = 4;
32+
sint32 icon = 5;
33+
repeated string tags = 6;
3234
}
3335

3436
message LxnsListRequest {

src/Render/Drawer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ namespace Limekuma.Render;
99
public sealed class Drawer
1010
{
1111
public async Task<Image> DrawBestsAsync(CommonUser user, IList<CommonRecord> ever,
12-
IList<CommonRecord> current, int everTotal, int currentTotal, string prober, IList<string> tags) =>
13-
await DrawBestsAsync(user, ever, current, everTotal, currentTotal, prober, tags, "./Resources/Layouts/bests.xml");
12+
IList<CommonRecord> current, int everTotal, int currentTotal, string? condition, string prober, IList<string> tags) =>
13+
await DrawBestsAsync(user, ever, current, everTotal, currentTotal, condition, prober, tags, "./Resources/Layouts/bests.xml");
1414

1515
public async Task<Image> DrawBestsAsync(CommonUser user, IList<CommonRecord> ever,
16-
IList<CommonRecord> current, int everTotal, int currentTotal, string prober, IList<string> tags, string xmlPath)
16+
IList<CommonRecord> current, int everTotal, int currentTotal, string? condition, string prober, IList<string> tags, string xmlPath)
1717
{
1818
int everMax = ever.Count > 0 ? ever[0].DXRating : 0;
1919
int everMin = ever.Count > 0 ? ever[^1].DXRating : 0;
2020
int currentMax = current.Count > 0 ? current[0].DXRating : 0;
2121
int currentMin = current.Count > 0 ? current[^1].DXRating : 0;
2222
bool mayMask = ever.Any(r => r.DXScore is 0 && (r.DXStar > 0 || r.Rank > Ranks.A)) || current.Any(r => r.DXScore is 0 && (r.DXStar > 0 || r.Rank > Ranks.A));
23-
Dictionary<string, object> scope = new(StringComparer.OrdinalIgnoreCase)
23+
Dictionary<string, object?> scope = new(StringComparer.OrdinalIgnoreCase)
2424
{
2525
["userInfo"] = user,
2626
["everRecords"] = ever,
2727
["currentRecords"] = current,
2828
["everRating"] = everTotal,
2929
["currentRating"] = currentTotal,
30+
["condition"] = condition,
3031
["proberName"] = prober,
3132
["tags"] = tags,
3233
["mayMask"] = mayMask,
@@ -48,7 +49,7 @@ public async Task<Image> DrawListAsync(CommonUser user, IList<CommonRecord> reco
4849
List<int> countList = [.. counts];
4950
int totalCount = counts.Count > 0 ? counts[^1] : 0;
5051
bool mayMask = records.Any(r => r.DXScore is 0 && (r.DXStar > 0 || r.Rank > Ranks.A));
51-
Dictionary<string, object> scope = new(StringComparer.OrdinalIgnoreCase)
52+
Dictionary<string, object?> scope = new(StringComparer.OrdinalIgnoreCase)
5253
{
5354
["userInfo"] = user,
5455
["pageRecords"] = records,
@@ -66,7 +67,7 @@ public async Task<Image> DrawListAsync(CommonUser user, IList<CommonRecord> reco
6667
return await DrawAsync(scope, xmlPath);
6768
}
6869

69-
private async Task<Image> DrawAsync(IDictionary<string, object> scope, string xmlPath)
70+
private async Task<Image> DrawAsync(IDictionary<string, object?> scope, string xmlPath)
7071
{
7172
AsyncNCalcEngine expr = new();
7273
RegisterFunctions(expr);

src/Services/DfBestsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public override async Task GetFromDivingFish(DivingFishBestsRequest request,
5353
(CommonUser user, List<CommonRecord> bestEver, List<CommonRecord> bestCurrent, int everTotal,
5454
int currentTotal) = await PrepareDfDataAsync(request.Qq, request.Frame, request.Plate, request.Icon);
5555
using Image bestsImage = await new Drawer().DrawBestsAsync(user, bestEver, bestCurrent, everTotal, currentTotal,
56-
"divingfish", request.Tags);
56+
request.Condition, "divingfish", request.Tags);
5757

5858
await responseStream.WriteToResponseAsync(bestsImage);
5959
}

src/Services/LxnsBestsService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public override async Task GetFromLxns(LxnsBestsRequest request, IServerStreamWr
9494
(CommonUser user, List<CommonRecord> bestEver, List<CommonRecord> bestCurrent, int everTotal,
9595
int currentTotal) = await PrepareLxnsDataAsync(request.DevToken, request.Qq, request.PersonalToken);
9696
using Image bestsImage =
97-
await new Drawer().DrawBestsAsync(user, bestEver, bestCurrent, everTotal, currentTotal, "lxns", request.Tags);
97+
await new Drawer().DrawBestsAsync(user, bestEver, bestCurrent, everTotal, currentTotal, request.Condition,
98+
"lxns", request.Tags);
9899

99100
await responseStream.WriteToResponseAsync(bestsImage);
100101
}

0 commit comments

Comments
 (0)