@@ -3,6 +3,8 @@ import type { PlayerResp, UnitsResp } from "./requestMaker.ts";
33import { profileStatMappings , playerMappings , galacticPowerMappings , speedModMappings , pipMappings , relicMappings , gearMappings , rarityMappings } from "./listBuilderMappings.ts" ;
44import { getSpeedModCount , getPipCount , countOffensePercentRolls } from "./mods.ts" ;
55import { ULLocation , relicChart , gearChart , starChart , activeChart } from "./locations.ts"
6+ import { getWins } from "./grand-arena/main.ts"
7+ import { getInstanceIds } from "./grand-arena/getRecentRounds.ts"
68
79function handleLastSeen ( player : PlayerResp ) : void {
810 let lastSeen = new Date ( Number ( player . lastActivityTime ) ) . toLocaleString ( ) ;
@@ -136,6 +138,35 @@ function checkIfShip(units: UnitsResp[], defId: string): boolean {
136138 return false ;
137139}
138140
141+ async function handleGACWins ( player : PlayerResp ) : Promise < void > {
142+ let gp = 0 ;
143+ galacticPowerMappings . forEach ( stat => {
144+ const playerStat = player . profileStat . find ( ps => ps . index === stat . index )
145+ if ( playerStat ) {
146+ gp = Number ( playerStat . value ) ;
147+ }
148+ } ) ;
149+ if ( gp === 0 ) {
150+ console . error ( "Found a player with 0 GP..." ) ;
151+ return ;
152+ }
153+
154+ const wins = await getWins ( player . playerId , gp ) ;
155+ const recent3v3 = await getInstanceIds ( "3v3" ) ;
156+ const recent5v5 = await getInstanceIds ( "5v5" ) ;
157+ if ( ! wins || ! recent3v3 || ! recent5v5 ) {
158+ console . error ( "Missing wins, recent3v3, or recent5v5 in handleGACWins()" ) ;
159+ return ;
160+ }
161+
162+ let seasons : number [ ] = [ ] ;
163+ seasons . push ( recent3v3 . season ) ;
164+ seasons . push ( recent5v5 . season ) ;
165+ seasons . sort ( ( a , b ) => a - b ) ;
166+
167+ ULLocation ( "gacInfo" , `Wins in seasons ${ seasons [ 0 ] } and ${ seasons [ 1 ] } : ${ wins } ` ) ;
168+ }
169+
139170export async function FillList ( allyCode : string ) {
140171 const units = await getUnits ( ) ;
141172 if ( ! units ) {
@@ -190,6 +221,9 @@ export async function FillList(allyCode: string) {
190221 case 10 :
191222 handleLastSeen ( player ) ;
192223 break ;
224+ case 11 :
225+ await handleGACWins ( player ) ;
226+ break ;
193227 default :
194228 console . error ( `Found unknown playerMappings key: ${ key } ` )
195229 }
0 commit comments