fork/replay-manager-for-slippi
git clone https://git.julia.blue/fork/replay-manager-for-slippi
edcc927
main
1import { init , SlpGame , PlayerAnalysis , GameSettings } from 'slp-enforcer' ; 2import { EnforcePlayerFailure } from '../common/types' ; 3 4window . onload = async () => { 5await init (); 6window . electron . onEnforcer ( async ( event , replays , replayLoadCount ) => { 7try { 8window . electron . sendEnforcerResults ( 9( 10await Promise . all ( 11replays . map ( async ( replay ) => { 12let slpGame :SlpGame | undefined ; 13try { 14slpGame = new SlpGame ( replay . array ); 15const playerFailures :EnforcePlayerFailure [] = []; 16if ( slpGame . isSlpMinVersion ()) { 17return { fileName :replay . fileName , playerFailures}; 18} 19 20const validPorts = new Set ( 21( slpGame . getGameSettings () as GameSettings ). players 22. filter (( player ) => player . playerType === 0 ) 23. map (( player ) => player . playerIndex + 1 ), 24); 25for ( let port = 1 ; port < 5 ; port += 1 ) { 26if ( validPorts . has ( port )) { 27const playerFailure :EnforcePlayerFailure = { 28checkNames :[], 29 port, 30}; 31const playerAnalysis :PlayerAnalysis = 32slpGame . analyzePlayer ( port - 1 ); 33if ( playerAnalysis . crouch_uptilt ?. result ) { 34playerFailure . checkNames . push ( 'Fast Crouch Uptilt' ); 35} 36if ( playerAnalysis . disallowed_cstick ?. result ) { 37playerFailure . checkNames . push ( 38'Disallowed Analog C-Stick Values' , 39); 40} 41if ( playerAnalysis . goomwave ?. result ) { 42playerFailure . checkNames . push ( 'GoomWave Clamping' ); 43} 44if ( playerAnalysis . sdi ?. result ) { 45playerFailure . checkNames . push ( 'Illegal SDI' ); 46} 47if ( playerAnalysis . travel_time ?. result ) { 48playerFailure . checkNames . push ( 'Box Travel Time' ); 49} 50if ( playerAnalysis . uptilt_rounding ?. result ) { 51playerFailure . checkNames . push ( 'Uptilt Rounding' ); 52} 53if ( 54playerAnalysis . input_fuzzing && 55! playerAnalysis . input_fuzzing . pass 56) { 57playerFailure . checkNames . push ( 'Input Fuzzing' ); 58} 59if ( playerFailure . checkNames . length > 0 ) { 60// suppress known box sdi false positive 61if ( 62playerFailure . checkNames . length > 1 || 63playerFailure . checkNames [ 0 ] !== 'Illegal SDI' || 64playerAnalysis . controller_type === 'Analog' 65) { 66playerFailures . push ( playerFailure ); 67} 68} 69} 70} 71return { fileName :replay . fileName , playerFailures}; 72} finally { 73slpGame ?. free (); 74} 75}), 76) 77). filter (({ playerFailures}) => playerFailures . length > 0 ), 78replayLoadCount , 79); 80} catch ( e :any ) { 81window . electron . sendEnforcerError ( e , replayLoadCount ); 82} 83}); 84};