Skip to content

Commit 6d30283

Browse files
committed
fix(ScoreFilter): Fix the enumeration comparison logic for ComboFlags and SyncFlags
- Changed `x.ComboFlag >= comboFlag` in ComboScoreFilter to use the `HasFlag` method - Fixed the counting logic for ComboFlags and SyncFlags in ListService, replacing `>=` comparison with `HasFlag` - Adjusted the field order of the AchievementInfoRequest message - Renamed ConstantMap.VersionMap to GenreMap and added the corresponding GenreScoreFilter - Added FilterScoreProcesser for handling record filtering - Updated the default icon IDs in DfBestsService and LxnsBestsService - Added the Flags attribute to the ComboFlags and SyncFlags enumerations and redefined the enumeration values
1 parent 2fa8a0e commit 6d30283

File tree

10 files changed

+84
-40
lines changed

10 files changed

+84
-40
lines changed

src/Prober/Common/ComboFlags.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
namespace Limekuma.Prober.Common;
44

5+
[Flags]
56
[JsonConverter(typeof(JsonStringEnumConverter<ComboFlags>))]
67
public enum ComboFlags
78
{
8-
None,
9+
[JsonIgnore]
10+
None = 0b0000_0000,
11+
12+
[JsonIgnore]
13+
Plus = 0b0000_0001,
914

1015
[JsonStringEnumMemberName("fc")]
11-
FullCombo,
16+
FullCombo = 0b0000_0010,
1217

1318
[JsonStringEnumMemberName("fcp")]
14-
FullComboPlus,
19+
FullComboPlus = FullCombo | Plus,
1520

1621
[JsonStringEnumMemberName("ap")]
17-
AllPerfect,
22+
AllPerfect = 0b0000_0100,
1823

1924
[JsonStringEnumMemberName("app")]
20-
AllPerfectPlus
25+
AllPerfectPlus = AllPerfect | Plus
2126
}

src/Prober/Common/SyncFlags.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@
22

33
namespace Limekuma.Prober.Common;
44

5+
[Flags]
56
[JsonConverter(typeof(JsonStringEnumConverter<SyncFlags>))]
67
public enum SyncFlags
78
{
8-
None,
9+
[JsonIgnore]
10+
None = 0b0000_0000,
11+
12+
[JsonStringEnumMemberName("sync")]
13+
SyncPlay = 0b0000_0001,
14+
15+
[JsonIgnore]
16+
Full = 0b0000_0010,
917

1018
[JsonStringEnumMemberName("fs")]
11-
FullSync,
19+
FullSync = Full | SyncPlay,
20+
21+
[JsonIgnore]
22+
Plus = 0b0000_0100,
1223

1324
[JsonStringEnumMemberName("fsp")]
14-
FullSyncPlus,
25+
FullSyncPlus = Full | SyncPlay | Plus,
26+
27+
[JsonIgnore]
28+
DX = 0b0000_1000,
1529

1630
[JsonStringEnumMemberName("fsd")]
17-
FullSyncDX,
31+
FullSyncDX = Full | SyncPlay | DX,
1832

1933
[JsonStringEnumMemberName("fsdp")]
20-
FullSyncDXPlus,
21-
22-
[JsonStringEnumMemberName("sync")]
23-
SyncPlay
34+
FullSyncDXPlus = Full | SyncPlay | DX | Plus
2435
}

src/Protos/kumabot.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ message ChartInfoRequest {
8181

8282
message AchievementInfoRequest {
8383
string prober = 1;
84-
string difficulty = 2;
85-
string songId = 3;
84+
string songId = 2;
85+
string difficulty = 3;
8686
}
8787

8888
message ImageResponse {

src/ScoreFilter/ComboScoreFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public Func<CommonRecord, bool> GetFilter(string? condition)
1212
return _ => true;
1313
}
1414

15-
return x => x.ComboFlag >= comboFlag;
15+
return x => x.ComboFlag.HasFlag(comboFlag);
1616
}
1717
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Limekuma.ScoreFilter;
66

7-
[ScoreFilterTag("version")]
8-
public sealed class VersionScoreFilter : IScoreFilter
7+
[ScoreFilterTag("genre")]
8+
public sealed class GenreScoreFilter : IScoreFilter
99
{
1010
public Func<CommonRecord, bool> GetFilter(string? condition)
1111
{
@@ -14,11 +14,11 @@ public Func<CommonRecord, bool> GetFilter(string? condition)
1414
return _ => true;
1515
}
1616

17-
if (!ConstantMap.VersionMap.TryGetValue(condition, out FrozenSet<string>? version))
17+
if (!ConstantMap.GenreMap.TryGetValue(condition, out FrozenSet<string>? genre))
1818
{
1919
return _ => true;
2020
}
2121

22-
return x => version.Contains(x.Chart.Song.Genre);
22+
return x => genre.Contains(x.Chart.Song.Genre);
2323
}
2424
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Limekuma.Prober.Common;
2+
using Limekuma.Utils;
3+
using System.Collections.Immutable;
4+
5+
namespace Limekuma.ScoreProcesser;
6+
7+
[ScoreProcesserTag("filter")]
8+
public sealed class FilterScoreProcesser : IScoreProcesser
9+
{
10+
public (ImmutableArray<CommonRecord>, ImmutableArray<CommonRecord>) Process(IReadOnlyList<CommonRecord> records)
11+
{
12+
(ImmutableArray<CommonRecord>.Builder Ever, ImmutableArray<CommonRecord>.Builder Current) state = (
13+
ImmutableArray.CreateBuilder<CommonRecord>(35), ImmutableArray.CreateBuilder<CommonRecord>(15));
14+
(ImmutableArray<CommonRecord>.Builder Ever, ImmutableArray<CommonRecord>.Builder Current) rankedState = records
15+
.SortRecordForBests().Aggregate(state, static (acc, record) =>
16+
{
17+
if (acc.Ever.Count >= 35 && acc.Current.Count >= 15)
18+
{
19+
return acc;
20+
}
21+
22+
(record.Chart.Song.InCurrentGenre switch
23+
{
24+
true => acc.Current,
25+
false => acc.Ever
26+
}).Add(record);
27+
return acc;
28+
});
29+
ImmutableArray<CommonRecord>.Builder ever = rankedState.Ever;
30+
ImmutableArray<CommonRecord>.Builder current = rankedState.Current;
31+
return (ever.ToImmutable(), current.ToImmutable());
32+
}
33+
}

src/Services/DfBestsService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public partial class BestsService
9090
TrophyText = "でらっくま",
9191
CourseRank = CommonCourseRank.Urakaiden,
9292
ClassRank = ClassRank.LEGEND,
93-
IconId = 1,
94-
PlateId = 1,
95-
FrameId = 1
93+
IconId = 101,
94+
PlateId = 55103,
95+
FrameId = 109102
9696
};
9797

9898
await PrepareDataAsync(user, bestEver, bestCurrent);

src/Services/ListService.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,47 +79,42 @@ private static void AccumulateRecordStats(CommonRecord record, int[] counts)
7979
counts[6]++;
8080
}
8181

82-
if (record.ComboFlag >= ComboFlags.AllPerfectPlus)
82+
if (record.ComboFlag.HasFlag(ComboFlags.AllPerfectPlus))
8383
{
8484
counts[7]++;
8585
}
8686

87-
if (record.ComboFlag >= ComboFlags.AllPerfect)
87+
if (record.ComboFlag.HasFlag(ComboFlags.AllPerfect))
8888
{
8989
counts[8]++;
9090
}
9191

92-
if (record.ComboFlag >= ComboFlags.FullComboPlus)
92+
if (record.ComboFlag.HasFlag(ComboFlags.FullComboPlus))
9393
{
9494
counts[9]++;
9595
}
9696

97-
if (record.ComboFlag >= ComboFlags.FullCombo)
97+
if (record.ComboFlag.HasFlag(ComboFlags.FullCombo))
9898
{
9999
counts[10]++;
100100
}
101101

102-
if (record.SyncFlag is SyncFlags.SyncPlay)
103-
{
104-
return;
105-
}
106-
107-
if (record.SyncFlag >= SyncFlags.FullSyncDXPlus)
102+
if (record.SyncFlag.HasFlag(SyncFlags.FullSyncDXPlus))
108103
{
109104
counts[11]++;
110105
}
111106

112-
if (record.SyncFlag >= SyncFlags.FullSyncDX)
107+
if (record.SyncFlag.HasFlag(SyncFlags.FullSyncDX))
113108
{
114109
counts[12]++;
115110
}
116111

117-
if (record.SyncFlag >= SyncFlags.FullSyncPlus)
112+
if (record.SyncFlag.HasFlag(SyncFlags.FullSyncPlus))
118113
{
119114
counts[13]++;
120115
}
121116

122-
if (record.SyncFlag >= SyncFlags.FullSync)
117+
if (record.SyncFlag.HasFlag(SyncFlags.FullSync))
123118
{
124119
counts[14]++;
125120
}

src/Services/LxnsBestsService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public partial class BestsService
8686
TrophyText = "でらっくま",
8787
CourseRank = CommonCourseRank.Urakaiden,
8888
ClassRank = ClassRank.LEGEND,
89-
IconId = 1,
90-
PlateId = 1,
91-
FrameId = 1
89+
IconId = 101,
90+
PlateId = 55103,
91+
FrameId = 109102
9292
};
9393

9494
await PrepareDataAsync(user, bestEver, bestCurrent);

src/Utils/ConstantMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private static readonly (float, float, float)[] RatingFactors =
2424
(101, 0.224f, 15)
2525
];
2626

27-
public static readonly FrozenDictionary<string, FrozenSet<string>> VersionMap =
27+
public static readonly FrozenDictionary<string, FrozenSet<string>> GenreMap =
2828
new Dictionary<string, FrozenSet<string>>
2929
{
3030
["真"] = ["maimai", "maimai PLUS"],

0 commit comments

Comments
 (0)