@@ -43,60 +43,52 @@ public ImportChartCheckResult ImportChartCheck(IFormFile file, [FromForm] bool i
4343 fatal = true ;
4444 }
4545
46- var levels = new bool [ 5 ] ;
4746 var allChartText = new Dictionary < int , string > ( ) ;
48-
49- for ( var i = 0 ; i < 5 ; i ++ )
47+ for ( var i = 0 ; i < 9 ; i ++ )
5048 {
51- // maidata 里 2 是绿谱,6 是白谱
52- if ( ! string . IsNullOrWhiteSpace ( maiData . GetValueOrDefault ( $ "inote_{ i + 2 } ") ) )
49+ if ( i == 1 ) continue ; // maidata 中 inote_1 无对应游戏难度,与 ImportMaidata 保持一致
50+ if ( ! string . IsNullOrWhiteSpace ( maiData . GetValueOrDefault ( $ "inote_{ i } ") ) )
5351 {
54- levels [ i ] = true ;
55- allChartText . Add ( i + 2 , maiData . GetValueOrDefault ( $ "inote_{ i + 2 } ") ) ;
52+ allChartText . Add ( i , maiData . GetValueOrDefault ( $ "inote_{ i } ") ) ;
5653 }
5754 }
55+ var targetLevelMap = MaidataImportService . MapMaidataLevelToGame ( allChartText . Keys . ToList ( ) ) ;
5856
59- if ( levels . Any ( it => it ) )
57+ # region 向前端返回,关于导入谱面的inote_映射到游戏中的难度的提示信息
58+ string [ ] levelNames = [ Locale . DifficultyBasic , Locale . DifficultyAdvanced , Locale . DifficultyExpert , Locale . DifficultyMaster , Locale . DifficultyReMaster ] ;
59+ string [ ] importAsMessages = [ Locale . DifficultyImportedAsBasic , null , null , Locale . DifficultyImportedAsMaster , Locale . DifficultyImportedAsReMaster ] ;
60+
61+ string generalImportMessage = "" ; // “将导入以下难度:” 的默认信息
62+ var extraImportMessages = new List < string > ( ) ; // “有一个难度为 {0} 的谱面,将导入为XX谱 ” 的信息
63+ foreach ( var ( lv , _) in allChartText )
6064 {
61- string [ ] levelNames = [ Locale . DifficultyBasic , Locale . DifficultyAdvanced , Locale . DifficultyExpert , Locale . DifficultyMaster , Locale . DifficultyReMaster ] ;
62- var message = Locale . ImportingDifficulties ;
63- for ( var i = 0 ; i < 5 ; i ++ )
64- {
65- if ( levels [ i ] )
66- {
67- message += levelNames [ i ] + " " ;
68- }
65+ if ( ! targetLevelMap . TryGetValue ( lv , out var targetLevel ) )
66+ { // 根据targetLevelMap返回的结果,该谱面应被忽略
67+ extraImportMessages . Add ( string . Format ( Locale . DifficultyIgnored , lv ) ) ;
68+ continue ;
6969 }
70-
71- errors . Add ( new ImportChartMessage ( message , MessageLevel . Info ) ) ;
72- }
73-
74- foreach ( var i in ( int [ ] ) [ 7 , 8 , 0 ] )
75- {
76- if ( string . IsNullOrWhiteSpace ( maiData . GetValueOrDefault ( $ "inote_{ i } ") ) ) continue ;
77- allChartText . Add ( i , maiData . GetValueOrDefault ( $ "inote_{ i } ") ) ;
78- if ( ! levels [ 3 ] )
70+ if ( 2 <= lv && lv <= 6 )
7971 {
80- levels [ 3 ] = true ;
81- errors . Add ( new ImportChartMessage ( string . Format ( Locale . DifficultyImportedAsMaster , i ) , MessageLevel . Warning ) ) ;
82- }
83- else if ( ! levels [ 4 ] )
84- {
85- levels [ 4 ] = true ;
86- errors . Add ( new ImportChartMessage ( string . Format ( Locale . DifficultyImportedAsReMaster , i ) , MessageLevel . Warning ) ) ;
87- }
88- else if ( ! levels [ 0 ] )
89- {
90- levels [ 0 ] = true ;
91- errors . Add ( new ImportChartMessage ( string . Format ( Locale . DifficultyImportedAsBasic , i ) , MessageLevel . Warning ) ) ;
72+ generalImportMessage += levelNames [ targetLevel ] + " " ;
9273 }
9374 else
9475 {
95- errors . Add ( new ImportChartMessage ( string . Format ( Locale . DifficultyIgnored , i ) , MessageLevel . Warning ) ) ;
76+ extraImportMessages . Add ( string . Format ( importAsMessages [ targetLevel ] , lv ) ) ;
9677 }
9778 }
79+
80+ if ( ! string . IsNullOrEmpty ( generalImportMessage ) )
81+ {
82+ errors . Add ( new ImportChartMessage ( Locale . ImportingDifficulties + generalImportMessage , MessageLevel . Info ) ) ;
83+ }
84+
85+ foreach ( var message in extraImportMessages )
86+ {
87+ errors . Add ( new ImportChartMessage ( message , MessageLevel . Warning ) ) ;
88+ }
89+ # endregion
9890
99- if ( ! levels . Any ( it => it ) )
91+ if ( targetLevelMap . Count == 0 ) // 没有能够被映射的谱面
10092 {
10193 errors . Add ( new ImportChartMessage ( Locale . MusicNoCharts , MessageLevel . Fatal ) ) ;
10294 fatal = true ;
0 commit comments