@@ -8,12 +8,12 @@ namespace Limekuma.Render;
88
99public sealed class Drawer
1010{
11- public async Task < Image > DrawBestsAsync ( CommonUser user , IList < CommonRecord > ever ,
12- IList < CommonRecord > current , int everTotal , int currentTotal , string ? condition , string prober , IList < string > tags ) =>
11+ public async Task < Image > DrawBestsAsync ( CommonUser user , IReadOnlyList < CommonRecord > ever ,
12+ IReadOnlyList < CommonRecord > current , int everTotal , int currentTotal , string ? condition , string prober , IEnumerable < string > tags ) =>
1313 await DrawBestsAsync ( user , ever , current , everTotal , currentTotal , condition , prober , tags , "./Resources/Layouts/bests.xml" ) ;
1414
15- public async Task < Image > DrawBestsAsync ( CommonUser user , IList < CommonRecord > ever ,
16- IList < CommonRecord > current , int everTotal , int currentTotal , string ? condition , string prober , IList < string > tags , string xmlPath )
15+ public async Task < Image > DrawBestsAsync ( CommonUser user , IReadOnlyList < CommonRecord > ever ,
16+ IReadOnlyList < CommonRecord > current , int everTotal , int currentTotal , string ? condition , string prober , IEnumerable < 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 ;
@@ -39,14 +39,13 @@ public async Task<Image> DrawBestsAsync(CommonUser user, IList<CommonRecord> eve
3939 return await DrawAsync ( scope , xmlPath ) ;
4040 }
4141
42- public async Task < Image > DrawListAsync ( CommonUser user , IList < CommonRecord > records , int page , int total ,
43- IList < int > counts , int startIndex , string condition , string prober , IList < string > tags ) =>
42+ public async Task < Image > DrawListAsync ( CommonUser user , IReadOnlyList < CommonRecord > records , int page , int total ,
43+ List < int > counts , int startIndex , string condition , string prober , IEnumerable < string > tags ) =>
4444 await DrawListAsync ( user , records , page , total , counts , startIndex , condition , prober , tags , "./Resources/Layouts/list.xml" ) ;
4545
46- public async Task < Image > DrawListAsync ( CommonUser user , IList < CommonRecord > records , int page , int total ,
47- IList < int > counts , int startIndex , string condition , string prober , IList < string > tags , string xmlPath )
46+ public async Task < Image > DrawListAsync ( CommonUser user , IReadOnlyList < CommonRecord > records , int page , int total ,
47+ List < int > counts , int startIndex , string condition , string prober , IEnumerable < string > tags , string xmlPath )
4848 {
49- List < int > countList = [ .. counts ] ;
5049 int totalCount = counts . Count > 0 ? counts [ ^ 1 ] : 0 ;
5150 bool mayMask = records . Any ( r => r . DXScore is 0 && ( r . DXStar > 0 || r . Rank > Ranks . A ) ) ;
5251 Dictionary < string , object ? > scope = new ( StringComparer . OrdinalIgnoreCase )
@@ -55,8 +54,8 @@ public async Task<Image> DrawListAsync(CommonUser user, IList<CommonRecord> reco
5554 [ "pageRecords" ] = records ,
5655 [ "pageNumber" ] = page ,
5756 [ "totalPages" ] = total ,
58- [ "rankCounts" ] = countList [ ..7 ] ,
59- [ "comboCounts" ] = countList [ 7 ..^ 1 ] ,
57+ [ "rankCounts" ] = counts [ ..7 ] ,
58+ [ "comboCounts" ] = counts [ 7 ..^ 1 ] ,
6059 [ "totalCount" ] = totalCount ,
6160 [ "startIndex" ] = startIndex ,
6261 [ "condition" ] = condition ,
@@ -67,7 +66,7 @@ public async Task<Image> DrawListAsync(CommonUser user, IList<CommonRecord> reco
6766 return await DrawAsync ( scope , xmlPath ) ;
6867 }
6968
70- private async Task < Image > DrawAsync ( IDictionary < string , object ? > scope , string xmlPath )
69+ private static async Task < Image > DrawAsync ( IDictionary < string , object ? > scope , string xmlPath )
7170 {
7271 AsyncNCalcEngine expr = new ( ) ;
7372 RegisterFunctions ( expr ) ;
@@ -77,7 +76,7 @@ private async Task<Image> DrawAsync(IDictionary<string, object?> scope, string x
7776 return NodeRenderer . Render ( ( CanvasNode ) tree , assets , assets ) ;
7877 }
7978
80- private void RegisterFunctions ( AsyncNCalcEngine expr )
79+ private static void RegisterFunctions ( AsyncNCalcEngine expr )
8180 {
8281 expr . RegisterFunction ( "ToString" , ( object x ) => Convert . ToString ( x ) ) ;
8382 expr . RegisterFunction ( "Count" , ( IList x ) => x . Count ) ;
0 commit comments