@@ -7,6 +7,17 @@ namespace Limekuma.Prober.DivingFish.Models;
77
88public class Record
99{
10+ private static CommonDifficulties MapDifficulty ( Difficulties difficulty ) => difficulty switch
11+ {
12+ Difficulties . Dummy => CommonDifficulties . Dummy ,
13+ Difficulties . Basic => CommonDifficulties . Basic ,
14+ Difficulties . Advanced => CommonDifficulties . Advanced ,
15+ Difficulties . Expert => CommonDifficulties . Expert ,
16+ Difficulties . Master => CommonDifficulties . Master ,
17+ Difficulties . ReMaster => CommonDifficulties . ReMaster ,
18+ _ => throw new InvalidDataException ( )
19+ } ;
20+
1021 [ JsonPropertyName ( "achievements" ) ]
1122 public required double Achievements { get ; init ; }
1223
@@ -53,69 +64,59 @@ public class Record
5364
5465 public string JacketUrl => $ "https://maimai.diving-fish.com/covers/{ Id } .png";
5566
56- public Song Song
57- {
58- get
59- {
60- field ??= Songs . Shared . First ( x => x . Id == Id . ToString ( ) ) ;
61- return field ;
62- }
63- }
67+ private Lazy < Song > ? _song ;
6468
65- public int TotalDXScore
66- {
67- get
68- {
69- if ( field is 0 )
70- {
71- field = Song . Charts [ DifficultyIndex ] . Notes . Sum ( ) * 3 ;
72- }
69+ public Song Song => ( _song ??= new ( ( ) => Songs . GetById ( Id . ToString ( ) ) ) ) . Value ;
7370
74- return field ;
75- }
76- }
71+ private Lazy < int > ? _totalDXScore ;
7772
78- public int DXStar
79- {
80- get
81- {
82- if ( field is not 0 )
83- {
84- return field ;
85- }
73+ public int TotalDXScore => ( _totalDXScore ??= new ( ( ) => Song . Charts [ DifficultyIndex ] . Notes . Total * 3 ) ) . Value ;
8674
87- double dxScorePersent = ( double ) DXScore / TotalDXScore ;
88- field = dxScorePersent switch
89- {
90- < 0.9 => 1 ,
91- < 0.93 => 2 ,
92- < 0.95 => 3 ,
93- < 0.97 => 4 ,
94- <= 1 => 5 ,
95- _ => throw new InvalidDataException ( )
96- } ;
97- return field ;
98- }
99- }
75+ private Lazy < int > ? _dxStar ;
10076
101- public static implicit operator CommonRecord ( Record record ) =>
102- new ( )
77+ public int DXStar => ( _dxStar ??= new ( ( ) => ( ( double ) DXScore / TotalDXScore ) switch
78+ {
79+ < 0.9 => 1 ,
80+ < 0.93 => 2 ,
81+ < 0.95 => 3 ,
82+ < 0.97 => 4 ,
83+ <= 1 => 5 ,
84+ _ => throw new InvalidDataException ( )
85+ } ) ) . Value ;
86+
87+ public static implicit operator CommonRecord ( Record record )
88+ {
89+ Song song = record . Song ;
90+ Chart chart = song . Charts [ record . DifficultyIndex ] ;
91+ BasicInfo basicInfo = song . BasicInfo ;
92+
93+ return new ( )
10394 {
104- Id = record . Id ,
105- Title = record . Title ,
106- Difficulty = ( CommonDifficulties ) record . Difficulty ,
95+ Chart = new ( )
96+ {
97+ Song = new ( )
98+ {
99+ Id = record . Id ,
100+ Title = record . Title ,
101+ Type = ( CommonSongTypes ) record . Type ,
102+ Genre = basicInfo . Genre ,
103+ InCurrentGenre = basicInfo . InCurrentVersion ,
104+ AudioUrl = record . AudioUrl ,
105+ JacketUrl = record . JacketUrl
106+ } ,
107+ Difficulty = MapDifficulty ( record . Difficulty ) ,
108+ TotalDXScore = record . TotalDXScore ,
109+ Level = record . Level ,
110+ LevelValue = record . LevelValue ,
111+ Notes = chart . Notes
112+ } ,
107113 ComboFlag = record . ComboFlag ,
108114 SyncFlag = record . SyncFlag ,
109115 Rank = record . Rank ,
110- Type = ( CommonSongTypes ) record . Type ,
111116 Achievements = record . Achievements ,
112117 DXRating = record . DXRating ,
113118 DXStar = record . DXStar ,
114- DXScore = record . DXScore ,
115- TotalDXScore = record . TotalDXScore ,
116- LevelValue = record . LevelValue ,
117- InCurrentVersion = record . Song . BasicInfo . InCurrentVersion ,
118- AudioUrl = record . AudioUrl ,
119- JacketUrl = record . JacketUrl
119+ DXScore = record . DXScore
120120 } ;
121+ }
121122}
0 commit comments