Skip to content

Commit 4c48926

Browse files
committed
feat: Add InCurrentVersion property to CommonRecord and implement comparer
Added the InCurrentVersion field to the DivingFish and Lxns data models to indicate whether a song is available in the current version. Also made CommonRecord implement the IComparer interface, providing comparison logic for sorting by DXRating, LevelValue, and Achievements.
1 parent 24eeaa0 commit 4c48926

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

src/Prober/Common/CommonRecord.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Limekuma.Prober.Common;
22

3-
public record CommonRecord
3+
public record CommonRecord : IComparer<CommonRecord>
44
{
55
public required int Id { get; init; }
66

@@ -28,7 +28,41 @@ public record CommonRecord
2828

2929
public required double LevelValue { get; init; }
3030

31+
public required bool InCurrentVersion { get; init; }
32+
3133
public string AudioUrl => $"https://assets2.lxns.net/maimai/music/{Id % 10000}.mp3";
3234

3335
public string JacketUrl => $"https://assets2.lxns.net/maimai/jacket/{Id % 10000}.png";
36+
37+
public int Compare(CommonRecord? x, CommonRecord? y)
38+
{
39+
if (x is null && y is null)
40+
{
41+
return 0;
42+
}
43+
44+
if (x is null)
45+
{
46+
return -1;
47+
}
48+
49+
if (y is null)
50+
{
51+
return 1;
52+
}
53+
54+
int result = x.DXRating.CompareTo(y.DXRating);
55+
if (result is not 0)
56+
{
57+
return result;
58+
}
59+
60+
result = x.LevelValue.CompareTo(y.LevelValue);
61+
if (result is not 0)
62+
{
63+
return result;
64+
}
65+
66+
return x.Achievements.CompareTo(y.Achievements);
67+
}
3468
}

src/Prober/DivingFish/Models/Record.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public static implicit operator CommonRecord(Record record) =>
113113
DXStar = record.DXStar,
114114
DXScore = record.DXScore,
115115
TotalDXScore = record.TotalDXScore,
116-
LevelValue = record.LevelValue
116+
LevelValue = record.LevelValue,
117+
InCurrentVersion = record.Song.BasicInfo.InCurrentVersion
117118
};
118119
}

src/Prober/Lxns/Models/Record.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public static implicit operator CommonRecord(Record record) =>
117117
DXStar = record.DXStar,
118118
DXScore = record.DXScore,
119119
TotalDXScore = record.TotalDXScore,
120-
LevelValue = record.LevelValue
120+
LevelValue = record.LevelValue,
121+
InCurrentVersion = (SongData.Shared.Versions[^1].VersionNumber / 100) == (record.Chart.Version / 100)
121122
};
122123
}

0 commit comments

Comments
 (0)