@@ -82,22 +82,38 @@ static void Main(string[] args)
8282 var context = scope . ServiceProvider . GetRequiredService < ReplayContext > ( ) ;
8383 var logger = scope . ServiceProvider . GetRequiredService < ILogger < Program > > ( ) ;
8484
85- var playerService = scope . ServiceProvider . GetRequiredService < IPlayerService > ( ) ;
86-
87- //var result = playerService.GetPlayerPlayerIdSummary(new(226401, 1, 2), RatingType.Cmdr, RatingCalcType.Dsstats)
88- // .GetAwaiter().GetResult();
85+ var minDate = new DateTime ( 2023 , 1 , 1 ) ;
86+ var query = from r in context . Replays
87+ from rp in r . ReplayPlayers
88+ from s in rp . Spawns
89+ from su in s . Units
90+ where r . GameTime > minDate && rp . Team == 1 && rp . Race == Commander . Zerg && s . Breakpoint == Breakpoint . All
91+ select su . Poss ;
92+ var posString = query . ToList ( ) ;
93+
94+ var allCoords = new List < ( int x , int y ) > ( ) ;
95+
96+ foreach ( var poss in posString )
97+ {
98+ var nums = poss
99+ . Split ( new [ ] { ',' } , StringSplitOptions . RemoveEmptyEntries )
100+ . Select ( int . Parse )
101+ . ToList ( ) ;
89102
90- //PlayerDetailRequest request = new()
91- //{
92- // RequestNames = new("PAX", 226401, 2, 1),
93- // TimePeriod = TimePeriod.Patch2_71,
94- // RatingType = RatingType.Cmdr,
95- //};
103+ for ( int i = 0 ; i < nums . Count - 1 ; i += 2 )
104+ {
105+ allCoords . Add ( ( nums [ i ] , nums [ i + 1 ] ) ) ;
106+ }
107+ }
96108
97- //var details = playerService.GetPlayerIdPlayerDetails(request).GetAwaiter().GetResult();
109+ int xMin = allCoords . Min ( p => p . x ) ;
110+ int xMax = allCoords . Max ( p => p . x ) ;
111+ int yMin = allCoords . Min ( p => p . y ) ;
112+ int yMax = allCoords . Max ( p => p . y ) ;
98113
99- var r = playerService . GetPlayerIdPlayerRatingDetails ( new ( 226401 , 1 , 2 ) , RatingType . Cmdr , RatingCalcType . Dsstats )
100- . GetAwaiter ( ) . GetResult ( ) ;
114+ // Output results
115+ Console . WriteLine ( $ "xMin: { xMin } , xMax: { xMax } ") ;
116+ Console . WriteLine ( $ "yMin: { yMin } , yMax: { yMax } ") ;
101117
102118 Console . ReadLine ( ) ;
103119 }
@@ -106,22 +122,22 @@ public static async Task GetWinrate(ReplayContext context)
106122 {
107123 DateTime fromDate = new DateTime ( 2023 , 07 , 01 ) ;
108124 var group = from r in context . Replays
109- from rp in r . ReplayPlayers
110- join rr in context . ReplayRatings on r . ReplayId equals rr . ReplayId
111- join rpr in context . RepPlayerRatings on rp . ReplayPlayerId equals rpr . ReplayPlayerId
112- where r . GameTime > fromDate
113- && r . Duration > 300
114- && rr . RatingType == RatingType . Cmdr
115- group new { rp , rr , rpr , r } by rp . Race into g
116- select new AvgResult ( )
117- {
118- Commander = g . Key ,
119- Count = g . Count ( ) ,
120- AvgRating = Math . Round ( g . Average ( a => a . rpr . Rating ) , 2 ) ,
121- AvgGain = Math . Round ( g . Average ( a => a . rpr . RatingChange ) , 2 ) ,
122- Wins = g . Sum ( s => s . rp . PlayerResult == PlayerResult . Win ? 1 : 0 ) ,
123- Replays = g . Select ( s => s . r . ReplayId ) . Distinct ( ) . Count ( )
124- } ;
125+ from rp in r . ReplayPlayers
126+ join rr in context . ReplayRatings on r . ReplayId equals rr . ReplayId
127+ join rpr in context . RepPlayerRatings on rp . ReplayPlayerId equals rpr . ReplayPlayerId
128+ where r . GameTime > fromDate
129+ && r . Duration > 300
130+ && rr . RatingType == RatingType . Cmdr
131+ group new { rp , rr , rpr , r } by rp . Race into g
132+ select new AvgResult ( )
133+ {
134+ Commander = g . Key ,
135+ Count = g . Count ( ) ,
136+ AvgRating = Math . Round ( g . Average ( a => a . rpr . Rating ) , 2 ) ,
137+ AvgGain = Math . Round ( g . Average ( a => a . rpr . RatingChange ) , 2 ) ,
138+ Wins = g . Sum ( s => s . rp . PlayerResult == PlayerResult . Win ? 1 : 0 ) ,
139+ Replays = g . Select ( s => s . r . ReplayId ) . Distinct ( ) . Count ( )
140+ } ;
125141
126142 var data = await group . ToListAsync ( ) ;
127143 data = data . Where ( x => ( int ) x . Commander > 3 ) . ToList ( ) ;
0 commit comments