fork/replay-manager-for-slippi
git clone https://git.julia.blue/fork/replay-manager-for-slippi
82b5e4d
2.5.1
1import { MatchResult , SlotState } from '@parry-gg/client' ; 2import { Backup , Report , VideogameAssetOff } from '@mui/icons-material' ; 3import { 4Avatar , 5Box , 6Button , 7CircularProgress , 8Dialog , 9DialogActions , 10DialogContent , 11DialogContentText , 12DialogTitle , 13Divider , 14IconButton , 15Stack , 16Tooltip , 17Typography , 18} from '@mui/material' ; 19import { MouseEventHandler , useEffect , useState } from 'react' ; 20import styled from '@emotion/styled' ; 21import { 22ChallongeMatchItem , 23EnforcerSetting , 24EnforceState , 25EnforceStatus , 26Id , 27Mode , 28ParryggGame , 29ParryggGameParticipant , 30Player , 31Replay , 32ReportSettings , 33Set , 34StartggGame , 35StartggGameSelection , 36StartggSet , 37State , 38Stream , 39} from '../common/types' ; 40import { 41characterNames , 42characterParryggSlugs , 43characterStartggIds , 44isValidCharacter , 45parryggCharacterColors , 46stageNames , 47stageParryggSlugs , 48stageStartggIds , 49startggCharacterIds , 50startggStageIds , 51} from '../common/constants' ; 52import LabeledCheckbox from './LabeledCheckbox' ; 53import getCharacterIcon from './getCharacterIcon' ; 54import { assertInteger , assertString } from '../common/asserts' ; 55 56const bgColor = 'rgba(34, 178, 76, 0.2)' ; 57 58function getCharacterIconInner ( 59characterId :number | undefined , 60costumeIndex ?:number , 61) { 62if ( characterId === undefined ) { 63return getCharacterIcon ( 31 , 0 ); 64} 65if ( costumeIndex === undefined ) { 66return getCharacterIcon ( characterId , 0 ); 67} 68return getCharacterIcon ( characterId , costumeIndex ); 69} 70 71const EntrantSection = styled ( Stack ) ` 72align-items: center; 73width: 50%; 74` ; 75 76const EntrantText = styled ( Stack ) ` 77margin: 0 4px; 78min-width: 0; 79` ; 80 81const EntrantScore = styled ( EntrantText ) ` 82width: 16px; 83` ; 84 85const Name = styled . div ` 86overflow-x: hidden; 87text-overflow: ellipsis; 88white-space: nowrap; 89` ; 90 91function isValid ( player :Player ) { 92return player . playerType === 0 || player . playerType === 1 ; 93} 94 95function setAndReplaysValid ( selectedReplays :Replay [], set :Set , mode :Mode ) { 96if ( selectedReplays . length === 0 ) { 97return { valid :false , reason :'No replays selected' }; 98} 99if ( mode === Mode . CHALLONGE && set . state === State . COMPLETED ) { 100return { valid :false , reason :'Set already completed' }; 101} 102 103let reason = '' ; 104const valid = selectedReplays . every (( replay , i ) => { 105if ( set . id === 0 ) { 106if ( ! reason ) { 107reason = 'No set selected' ; 108} 109return false ; 110} 111if ( Number . isInteger ( set . id ) && ( set . id as number ) < 0 ) { 112if ( ! reason ) { 113reason = 'Tiebreaker sets cannot be reported' ; 114} 115return false ; 116} 117 118const validPlayers = replay . players . filter ( isValid ); 119if ( 120validPlayers . length !== 121set . entrant1Participants . length + set . entrant2Participants . length 122) { 123if ( ! reason ) { 124reason = `Game ${ i + 1 } has wrong number of players` ; 125} 126return false ; 127} 128if ( ! ( validPlayers . find (( player ) => player . isWinner ) || replay . timeout )) { 129if ( ! reason ) { 130reason = `Game ${ i + 1 } does not have a winner` ; 131} 132return false ; 133} 134if ( ! validPlayers . every (( player ) => player . playerOverrides . entrantId )) { 135if ( ! reason ) { 136reason = `Game ${ i + 1 } does not have all players assigned` ; 137} 138return false ; 139} 140return true ; 141}); 142 143return { valid, reason}; 144} 145 146function getScoresAndWinnerId ( selectedReplays :Replay []) { 147let gameCount = 0 ; 148const gameWins = new Map < Id , number >(); 149let leaderId :Id = 0 ; 150let leaderWins = 0 ; 151selectedReplays . forEach (( replay ) => { 152const gameWinnerId = replay . players 153. filter ( isValid ) 154. find (( player ) => player . isWinner )?. playerOverrides . entrantId ; 155if ( ! gameWinnerId ) { 156return ; 157} 158 159const n = ( gameWins . get ( gameWinnerId ) || 0 ) + 1 ; 160if ( n > leaderWins ) { 161leaderWins = n ; 162leaderId = gameWinnerId ; 163} 164gameCount += 1 ; 165gameWins . set ( gameWinnerId , n ); 166}); 167 168return { 169scores :gameWins , 170winnerId :leaderWins / gameCount > 0.5 ?leaderId :0 , 171}; 172} 173 174function getDisplayNameFromPlayer ( player ?:Player ) { 175return player ?. playerOverrides . displayName || player ?. displayName ; 176} 177 178function ReportButton ({ 179 disabled, 180 elevate, 181 onClick, 182} :{ 183disabled ?:boolean ; 184elevate :boolean ; 185onClick ?:MouseEventHandler < HTMLButtonElement >; 186}) { 187return ( 188< Button 189disabled = { disabled } 190endIcon = {< Backup />} 191onClick = { onClick } 192size = "small" 193variant = "contained" 194sx = {{ 195zIndex :( theme ) => ( elevate ?theme . zIndex . drawer + 2 :undefined ), 196}} 197> 198Report 199</ Button > 200); 201} 202ReportButton . defaultProps = { 203disabled :false , 204onClick :undefined , 205}; 206 207export default function SetControls ({ 208 copyReplays, 209 deleteReplays, 210 reportChallongeSet, 211 reportStartggSet, 212 reportParryggSet, 213 reportOfflineModeSet, 214 setReportSettings, 215 resetGuide, 216 mode, 217 isCopying, 218 copyDisabled, 219 isDeleting, 220 dqId, 221 hasRemainingReplays, 222 reportSettings, 223 selectedReplays, 224 set, 225 elevate, 226 enforcerVersion, 227 enforcerSetting, 228 smuggleCostumeIndex, 229 wouldDeleteCopyDir, 230 replayLoadCount, 231 undoSubdir, 232} :{ 233copyReplays :( 234updatedSetFields ?:{ 235id :Id ; 236sggId :number | null ; 237completedAtMs :number ; 238stream :Stream | null ; 239}, 240violators ?:{ 241checkNames :Map < string , boolean >; 242displayName :string ; 243entrantId :Id ; 244}[], 245) => Promise < void >; 246deleteReplays :() => Promise < void >; 247reportChallongeSet :( 248matchId :string , 249items :ChallongeMatchItem [], 250) => Promise < Set >; 251reportStartggSet :( 252set :StartggSet , 253originalSet :Set , 254) => Promise < Set | undefined >; 255reportParryggSet :( 256result :MatchResult . AsObject , 257originalSet :Set , 258games ?:ParryggGame [], 259) => Promise < Set | undefined >; 260reportOfflineModeSet :( set :StartggSet ) => Promise < Set >; 261setReportSettings :( newReportSettings :ReportSettings ) => Promise < void >; 262resetGuide :() => void ; 263mode :Mode ; 264isCopying :boolean ; 265copyDisabled :boolean ; 266isDeleting :boolean ; 267dqId :Id ; 268hasRemainingReplays :boolean ; 269reportSettings :ReportSettings ; 270selectedReplays :Replay []; 271set :Set ; 272elevate :boolean ; 273enforcerVersion :string ; 274enforcerSetting :EnforcerSetting ; 275smuggleCostumeIndex :boolean ; 276wouldDeleteCopyDir :boolean ; 277replayLoadCount :number ; 278undoSubdir :string ; 279}) { 280const [ open , setOpen ] = useState ( false ); 281const [ reporting , setReporting ] = useState ( false ); 282const [ reportError , setReportError ] = useState ( '' ); 283const [ reportErrorOpen , setReportErrorOpen ] = useState ( false ); 284const [ startggSet , setStartggSet ] = useState < StartggSet >({ 285setId :set . id , 286winnerId :0 , 287isDQ :false , 288gameData :[], 289}); 290const [ challongeMatchItems , setChallongeMatchItems ] = useState < 291ChallongeMatchItem [] 292>([ 293{ 294participant_id :'' , 295score_set :'' , 296rank :0 , 297advancing :false , 298}, 299{ 300participant_id :'' , 301score_set :'' , 302rank :0 , 303advancing :false , 304}, 305]); 306const [ parryggMatchResult , setParryggMatchResult ] = 307useState < MatchResult . AsObject >({ 308slotsList :[ 309{ 310slot :0 , 311score :0 , 312state :SlotState . SLOT_STATE_NUMERIC , 313}, 314{ 315slot :1 , 316score :0 , 317state :SlotState . SLOT_STATE_NUMERIC , 318}, 319], 320}); 321 322const [ enforcerResultOpen , setEnforcerResultOpen ] = useState ( false ); 323const [ enforceState , setEnforceState ] = useState < EnforceState >({ 324status :EnforceStatus . DONE , 325fileNameToPlayerFailures :new Map (), 326}); 327useEffect (() => { 328window . electron . onEnforceState ( 329( event , newEnforceState , newReplayLoadCount ) => { 330if ( newReplayLoadCount >= replayLoadCount ) { 331setEnforceState ( newEnforceState ); 332} 333}, 334); 335}, [ replayLoadCount ]); 336const selectedReplaysWithEnforceErrors = 337enforceState . status === EnforceStatus . DONE 338 ?selectedReplays . filter (( replay ) => 339enforceState . fileNameToPlayerFailures . has ( replay . fileName ), 340) 341 :[]; 342let showEnforcerPopup = false ; 343if ( enforcerSetting === EnforcerSetting . POP_UP_ALL ) { 344showEnforcerPopup = selectedReplaysWithEnforceErrors . length > 0 ; 345} else if ( enforcerSetting === EnforcerSetting . POP_UP_GOOMWAVE ) { 346showEnforcerPopup = selectedReplaysWithEnforceErrors . some (( replay ) => 347enforceState . fileNameToPlayerFailures 348. get ( replay . fileName ) ! 349. some (( enforcerPlayerError ) => 350enforcerPlayerError . checkNames . includes ( 'GoomWave Clamping' ), 351), 352); 353} 354 355const isDq = dqId === set . entrant1Id || dqId === set . entrant2Id ; 356const validSelections = setAndReplaysValid ( selectedReplays , set , mode ); 357let scores = new Map < Id , number >(); 358let winnerId :Id = 0 ; 359if ( validSelections . valid ) { 360({ scores, winnerId} = getScoresAndWinnerId ( selectedReplays )); 361} else if ( isDq ) { 362if ( dqId === set . entrant1Id ) { 363scores . set ( set . entrant1Id , - 1 ); 364scores . set ( set . entrant2Id , 0 ); 365winnerId = set . entrant2Id ; 366} else { 367scores . set ( set . entrant1Id , 0 ); 368scores . set ( set . entrant2Id , - 1 ); 369winnerId = set . entrant1Id ; 370} 371} 372 373const entrant1SetScore = scores . get ( set . entrant1Id ) || 0 ; 374const entrant2SetScore = scores . get ( set . entrant2Id ) || 0 ; 375 376const getStartggSet = () :StartggSet => { 377if ( isDq ) { 378return { setId :set . id , winnerId, isDQ :true , gameData :[] }; 379} 380 381const gameData :StartggGame [] = []; 382selectedReplays . forEach (( replay , i ) => { 383const gameWinnerId = replay . players . find (( player ) => player . isWinner ) 384?. playerOverrides . entrantId ; 385if ( ! gameWinnerId ) { 386return ; 387} 388 389const originalEntrant1Score = set . gameScores [ i ]?. entrant1Score ?? 0 ; 390const originalEntrant2Score = set . gameScores [ i ]?. entrant2Score ?? 0 ; 391let entrant1CostumeOffset = Math . floor ( originalEntrant1Score / 100 ) * 100 ; 392let entrant2CostumeOffset = Math . floor ( originalEntrant2Score / 100 ) * 100 ; 393let entrant1Stocks = originalEntrant1Score % 100 ; 394let entrant2Stocks = originalEntrant2Score % 100 ; 395const participantIdToSelection = new Map < Id , StartggGameSelection >(); 396const validPlayers = replay . players . filter ( 397( player ) => 398isValid ( player ) && isValidCharacter ( player . externalCharacterId ), 399); 400validPlayers . forEach (( player ) => { 401const { entrantId, participantId} = player . playerOverrides ; 402participantIdToSelection . set ( participantId , { 403characterId :characterStartggIds . get ( player . externalCharacterId ) ! , 404 entrantId, 405}); 406if ( validPlayers . length === 2 ) { 407if ( entrantId === set . entrant1Id ) { 408if ( smuggleCostumeIndex ) { 409entrant1CostumeOffset = ( player . costumeIndex + 1 ) * 100 ; 410} 411if ( player . stocksRemaining >= 0 ) { 412entrant1Stocks = player . stocksRemaining ; 413} 414} else { 415if ( smuggleCostumeIndex ) { 416entrant2CostumeOffset = ( player . costumeIndex + 1 ) * 100 ; 417} 418if ( player . stocksRemaining >= 0 ) { 419entrant2Stocks = player . stocksRemaining ; 420} 421} 422} 423}); 424const selections = [ 425 ...set . entrant1Participants . map ( 426( participant ) => participantIdToSelection . get ( participant . id ) ! , 427), 428 ...set . entrant2Participants . map ( 429( participant ) => participantIdToSelection . get ( participant . id ) ! , 430), 431]; 432gameData . push ({ 433entrant1Score :entrant1CostumeOffset + entrant1Stocks , 434entrant2Score :entrant2CostumeOffset + entrant2Stocks , 435gameNum :i + 1 , 436stageId :stageStartggIds . get ( replay . stageId ), 437 selections, 438winnerId :assertInteger ( gameWinnerId ), 439}); 440}); 441return { setId :set . id , winnerId, isDQ :false , gameData}; 442}; 443 444// Per-game character/color/stage data for parry.gg, mirroring getStartggSet. 445const getParryggGames = () :ParryggGame [] => { 446const games :ParryggGame [] = []; 447selectedReplays . forEach (( replay , i ) => { 448const gameWinnerId = replay . players . find (( player ) => player . isWinner ) 449?. playerOverrides . entrantId ; 450if ( ! gameWinnerId ) { 451return ; 452} 453 454// slot 0 = entrant1, slot 1 = entrant2 (matches getMatchResult). 455const slotParticipants :[ 456ParryggGameParticipant [], 457ParryggGameParticipant [], 458] = [[], []]; 459replay . players 460. filter ( 461( player ) => 462isValid ( player ) && isValidCharacter ( player . externalCharacterId ), 463) 464. forEach (( player ) => { 465const { entrantId, participantId} = player . playerOverrides ; 466const slotIndex = entrantId === set . entrant1Id ?0 :1 ; 467slotParticipants [ slotIndex ]. push ({ 468userId :participantId . toString (), 469characters :[ 470{ 471characterSlug :characterParryggSlugs . get ( 472player . externalCharacterId , 473) ! , 474color : 475parryggCharacterColors . get ( player . externalCharacterId )?.[ 476player . costumeIndex 477] ?? null , 478}, 479], 480}); 481}); 482 483const winnerSlotIndex = gameWinnerId === set . entrant1Id ?0 :1 ; 484games . push ({ 485index :i , 486stageSlug :stageParryggSlugs . get ( replay . stageId ), 487slots :[ 0 , 1 ]. map (( slot ) => ({ 488 slot, 489score :slot === winnerSlotIndex ?1 :0 , 490participants :slotParticipants [ slot ], 491})), 492}); 493}); 494return games ; 495}; 496 497const getChallongeMatchItems = () :ChallongeMatchItem [] => [ 498{ 499participant_id :set . entrant1Id . toString ( 10 ), 500score_set :entrant1SetScore . toString ( 10 ), 501rank :winnerId === set . entrant1Id ?1 :2 , 502advancing :winnerId === set . entrant1Id , 503}, 504{ 505participant_id :set . entrant2Id . toString ( 10 ), 506score_set :entrant2SetScore . toString ( 10 ), 507rank :winnerId === set . entrant2Id ?1 :2 , 508advancing :winnerId === set . entrant2Id , 509}, 510]; 511 512const getMatchResult = () :MatchResult . AsObject => { 513const entrant1Dq = isDq && dqId === set . entrant1Id ; 514const entrant2Dq = isDq && dqId === set . entrant2Id ; 515 516return { 517slotsList :[ 518{ 519slot :0 , 520score :entrant1Dq ?0 :entrant1SetScore , 521state :entrant1Dq 522 ?SlotState . SLOT_STATE_DQ 523 :SlotState . SLOT_STATE_NUMERIC , 524}, 525{ 526slot :1 , 527score :entrant2Dq ?0 :entrant2SetScore , 528state :entrant2Dq 529 ?SlotState . SLOT_STATE_DQ 530 :SlotState . SLOT_STATE_NUMERIC , 531}, 532], 533}; 534}; 535 536let deleteOverrideReason = '' ; 537if ( set . fullRoundText === 'Grand Final' && hasRemainingReplays ) { 538deleteOverrideReason = 'possible Grand Finals Reset replays detected' ; 539} else if ( wouldDeleteCopyDir ) { 540deleteOverrideReason = 'would delete replays in copy folder' ; 541} 542 543let reportCopyDeleteIntent = 'Report' ; 544if ( reportSettings . alsoCopy || undoSubdir ) { 545reportCopyDeleteIntent += ', Copy' ; 546} 547if ( 548( reportSettings . alsoCopy && 549reportSettings . alsoDelete && 550deleteOverrideReason . length === 0 ) || 551undoSubdir 552) { 553reportCopyDeleteIntent += ', Delete' ; 554} 555 556let reportCopyDeleteButton = reportCopyDeleteIntent ; 557if ( enforceState . status === EnforceStatus . PENDING ) { 558reportCopyDeleteButton = 'Checking with SLP Enforcer' ; 559} else if (( reportSettings . alsoCopy || undoSubdir ) && copyDisabled ) { 560reportCopyDeleteButton = 'Copy destination not set' ; 561} else if (( reportSettings . alsoCopy || undoSubdir ) && isCopying ) { 562reportCopyDeleteButton = 'Copying' ; 563} else if (( reportSettings . alsoDelete || undoSubdir ) && isDeleting ) { 564reportCopyDeleteButton = 'Deleting' ; 565} else if ( reporting ) { 566reportCopyDeleteButton = 'Reporting' ; 567} 568 569return ( 570<> 571{ validSelections . valid && ( winnerId || isDq ) ?( 572< ReportButton 573elevate = { elevate } 574onClick = {() => { 575if ( mode === Mode . STARTGG || mode === Mode . OFFLINE_MODE ) { 576setStartggSet ( getStartggSet ()); 577} else if ( mode === Mode . CHALLONGE ) { 578setChallongeMatchItems ( getChallongeMatchItems ()); 579} else if ( mode === Mode . PARRYGG ) { 580setParryggMatchResult ( getMatchResult ()); 581} 582if ( 583( selectedReplaysWithEnforceErrors . length > 0 && 584showEnforcerPopup ) || 585enforceState . status === EnforceStatus . ERROR 586) { 587setEnforcerResultOpen ( true ); 588} 589setOpen ( true ); 590}} 591/> 592) :( 593< Tooltip 594arrow 595title = { ! validSelections . valid ?validSelections . reason :'No winner' } 596> 597< div > 598< ReportButton disabled elevate = { elevate } /> 599</ div > 600</ Tooltip > 601)} 602< Dialog 603open = { open } 604onClose = {() => { 605setOpen ( false ); 606setStartggSet ({ 607setId :set . id , 608winnerId :0 , 609isDQ :false , 610gameData :[], 611}); 612}} 613> 614< DialogTitle typography = "body1" > 615Report set on { mode === Mode . STARTGG && 'start.gg' } 616{ mode === Mode . CHALLONGE && 'Challonge' } 617{ mode === Mode . PARRYGG && 'parry.gg' } 618{ mode === Mode . OFFLINE_MODE && 'Offline Mode' } 619</ DialogTitle > 620< DialogContent sx = {{ width :'500px' }}> 621< Stack > 622< Box sx = {{ typography :'caption' }} textAlign = "center" > 623{ set . fullRoundText } 624</ Box > 625< Stack 626alignItems = "center" 627direction = "row" 628sx = {{ typography :'h5' }} 629> 630< EntrantSection 631borderRight = { 1 } 632direction = "row-reverse" 633style = {{ 634backgroundColor : 635set . entrant1Id === winnerId ?bgColor :undefined , 636}} 637> 638< Box marginRight = "8px" width = "24px" textAlign = "right" > 639{ entrant1SetScore } 640</ Box > 641< Stack textAlign = "right" > 642< Name >{ set . entrant1Participants [ 0 ]. displayName }</ Name > 643{ set . entrant1Participants . length > 1 && ( 644< Name >{ set . entrant1Participants [ 1 ]. displayName }</ Name > 645)} 646</ Stack > 647</ EntrantSection > 648< EntrantSection 649borderLeft = { 1 } 650direction = "row" 651style = {{ 652backgroundColor : 653set . entrant2Id === winnerId ?bgColor :undefined , 654}} 655> 656< Box marginLeft = "8px" width = "24px" > 657{ entrant2SetScore } 658</ Box > 659< Stack > 660< Name >{ set . entrant2Participants [ 0 ]. displayName }</ Name > 661{ set . entrant2Participants . length > 1 && ( 662< Name >{ set . entrant2Participants [ 1 ]. displayName }</ Name > 663)} 664</ Stack > 665</ EntrantSection > 666</ Stack > 667</ Stack > 668< Divider sx = {{ marginTop :'16px' }} /> 669< Stack flexGrow = { 1 }> 670{( mode === Mode . STARTGG || mode === Mode . OFFLINE_MODE ) && 671startggSet . gameData . map (( gameData ) => ( 672< Stack key = { gameData . gameNum } marginTop = "8px" > 673{ gameData . stageId && ( 674< Box sx = {{ typography :'caption' }} textAlign = "center" > 675{ stageNames . get ( startggStageIds . get ( gameData . stageId ) ! )} 676</ Box > 677)} 678< Stack direction = "row" sx = {{ typography :'body2' }}> 679< EntrantSection borderRight = { 1 } direction = "row-reverse" > 680< Stack 681alignItems = "center" 682direction = "row-reverse" 683paddingTop = "4px" 684paddingBottom = "4px" 685paddingLeft = { 686set . entrant1Participants . length === 1 687 ?'4px' 688 :undefined 689} 690style = {{ 691backgroundColor : 692set . entrant1Id === gameData . winnerId 693 ?bgColor 694 :undefined , 695}} 696> 697< EntrantScore textAlign = "right" > 698{ set . entrant1Id === gameData . winnerId && 'W' } 699</ EntrantScore > 700{ set . entrant1Participants . length === 1 && ( 701< Avatar 702alt = { characterNames . get ( 703startggCharacterIds . get ( 704gameData . selections [ 0 ]. characterId , 705) ! , 706)} 707src = { getCharacterIconInner ( 708startggCharacterIds . get ( 709gameData . selections [ 0 ]. characterId , 710), 711gameData . entrant1Score >= 100 712 ?Math . floor ( gameData . entrant1Score / 100 ) - 1 713 :undefined , 714)} 715sx = {{ height :24 , width :24 }} 716variant = "square" 717/> 718)} 719{ set . entrant1Participants . length === 2 && ( 720<> 721< Avatar 722alt = { characterNames . get ( 723startggCharacterIds . get ( 724gameData . selections [ 1 ]. characterId , 725) ! , 726)} 727src = { getCharacterIconInner ( 728startggCharacterIds . get ( 729gameData . selections [ 1 ]. characterId , 730), 731)} 732sx = {{ height :24 , width :24 }} 733variant = "square" 734/> 735< Avatar 736alt = { characterNames . get ( 737startggCharacterIds . get ( 738gameData . selections [ 0 ]. characterId , 739) ! , 740)} 741src = { getCharacterIconInner ( 742startggCharacterIds . get ( 743gameData . selections [ 0 ]. characterId , 744), 745)} 746sx = {{ height :24 , width :24 }} 747variant = "square" 748/> 749</> 750)} 751</ Stack > 752{ set . entrant1Participants . length === 1 && 753set . entrant1Id === gameData . winnerId && 754gameData . entrant1Score % 100 && ( 755< Tooltip 756arrow 757placement = "left" 758title = { ` ${ gameData . entrant1Score % 100 } stock` } 759> 760< Stack 761alignItems = "end" 762direction = "row" 763gap = "1px" 764marginRight = "8px" 765height = "100%" 766> 767{[ 768 ...Array ( gameData . entrant1Score % 100 ). keys (), 769]. map (() => ( 770< Avatar 771src = { getCharacterIconInner ( 772startggCharacterIds . get ( 773gameData . selections [ 0 ]. characterId , 774), 775gameData . entrant1Score >= 100 776 ?Math . floor ( 777gameData . entrant1Score / 100 , 778) - 1 779 :undefined , 780)} 781sx = {{ height :12 , width :12 }} 782variant = "square" 783/> 784))} 785</ Stack > 786</ Tooltip > 787)} 788</ EntrantSection > 789< EntrantSection borderLeft = { 1 } direction = "row" > 790< Stack 791alignItems = "center" 792direction = "row" 793paddingTop = "4px" 794paddingBottom = "4px" 795paddingRight = { 796set . entrant2Participants . length === 1 797 ?'4px' 798 :undefined 799} 800style = {{ 801backgroundColor : 802set . entrant2Id === gameData . winnerId 803 ?bgColor 804 :undefined , 805}} 806> 807< EntrantScore > 808{ set . entrant2Id === gameData . winnerId && 'W' } 809</ EntrantScore > 810{ set . entrant2Participants . length === 1 && ( 811< Avatar 812alt = { characterNames . get ( 813startggCharacterIds . get ( 814gameData . selections [ 1 ]. characterId , 815) ! , 816)} 817src = { getCharacterIconInner ( 818startggCharacterIds . get ( 819gameData . selections [ 1 ]. characterId , 820), 821gameData . entrant2Score >= 100 822 ?Math . floor ( gameData . entrant2Score / 100 ) - 1 823 :undefined , 824)} 825sx = {{ height :24 , width :24 }} 826variant = "square" 827/> 828)} 829{ set . entrant2Participants . length === 2 && ( 830<> 831< Avatar 832alt = { characterNames . get ( 833startggCharacterIds . get ( 834gameData . selections [ 835set . entrant1Participants . length 836]. characterId , 837) ! , 838)} 839src = { getCharacterIconInner ( 840startggCharacterIds . get ( 841gameData . selections [ 842set . entrant1Participants . length 843]. characterId , 844), 845)} 846sx = {{ height :24 , width :24 }} 847variant = "square" 848/> 849< Avatar 850alt = { characterNames . get ( 851startggCharacterIds . get ( 852gameData . selections [ 853set . entrant1Participants . length + 1 854]. characterId , 855) ! , 856)} 857src = { getCharacterIconInner ( 858startggCharacterIds . get ( 859gameData . selections [ 860set . entrant1Participants . length + 1 861]. characterId , 862), 863)} 864sx = {{ height :24 , width :24 }} 865variant = "square" 866/> 867</> 868)} 869</ Stack > 870{ set . entrant2Participants . length === 1 && 871set . entrant2Id === gameData . winnerId && 872gameData . entrant2Score % 100 && ( 873< Tooltip 874arrow 875placement = "right" 876title = { ` ${ gameData . entrant2Score % 100 } stock` } 877> 878< Stack 879alignItems = "end" 880direction = "row" 881gap = "1px" 882marginLeft = "8px" 883height = "100%" 884> 885{[ 886 ...Array ( gameData . entrant2Score % 100 ). keys (), 887]. map (() => ( 888< Avatar 889src = { getCharacterIconInner ( 890startggCharacterIds . get ( 891gameData . selections [ 1 ]. characterId , 892), 893gameData . entrant2Score >= 100 894 ?Math . floor ( 895gameData . entrant2Score / 100 , 896) - 1 897 :undefined , 898)} 899sx = {{ height :12 , width :12 }} 900variant = "square" 901/> 902))} 903</ Stack > 904</ Tooltip > 905)} 906</ EntrantSection > 907</ Stack > 908</ Stack > 909))} 910</ Stack > 911< Divider sx = {{ marginTop :'8px' }} /> 912< Stack justifyContent = "flex-end" > 913< LabeledCheckbox 914checked = { reportSettings . alsoCopy || undoSubdir . length > 0 } 915disabled = { undoSubdir . length > 0 } 916label = "Copy replays after reporting" 917labelPlacement = "start" 918set = {( checked :boolean ) => { 919const newReportSettings = { ...reportSettings }; 920newReportSettings . alsoCopy = checked ; 921setReportSettings ( newReportSettings ); 922}} 923/> 924< LabeledCheckbox 925checked = { reportSettings . alsoDelete || undoSubdir . length > 0 } 926disabled = { 927! reportSettings . alsoCopy || 928deleteOverrideReason . length > 0 || 929undoSubdir . length > 0 930} 931label = { 932deleteOverrideReason . length > 0 933 ?`Delete disabled, ${ deleteOverrideReason } ` 934 :'...then delete originals and eject' 935} 936labelPlacement = "start" 937set = {( checked :boolean ) => { 938const newReportSettings = { ...reportSettings }; 939newReportSettings . alsoDelete = checked ; 940setReportSettings ( newReportSettings ); 941}} 942/> 943</ Stack > 944</ DialogContent > 945< DialogActions > 946{ enforceState . status === EnforceStatus . ERROR && ( 947< Tooltip arrow placement = "top" title = "SLP Enforcer Failure" > 948< IconButton 949onClick = {() => { 950setEnforcerResultOpen ( true ); 951}} 952> 953< Report /> 954</ IconButton > 955</ Tooltip > 956)} 957{ selectedReplaysWithEnforceErrors . length > 0 && ( 958< Tooltip 959arrow 960placement = "top" 961title = "Controller Ruleset Violation Detected" 962> 963< IconButton 964onClick = {() => { 965setEnforcerResultOpen ( true ); 966}} 967> 968< VideogameAssetOff /> 969</ IconButton > 970</ Tooltip > 971)} 972< Button 973disabled = { 974reporting || 975( reportSettings . alsoCopy && isCopying ) || 976( reportSettings . alsoCopy && copyDisabled ) || 977enforceState . status === EnforceStatus . PENDING 978} 979endIcon = { 980reporting || enforceState . status === EnforceStatus . PENDING ?( 981< CircularProgress size = "24px" /> 982) :( 983< Backup /> 984) 985} 986onClick = { async () => { 987setReporting ( true ); 988try { 989let updatedSet :Set | undefined ; 990if ( mode === Mode . STARTGG ) { 991updatedSet = await reportStartggSet ( startggSet , set ); 992} else if ( mode === Mode . CHALLONGE ) { 993updatedSet = await reportChallongeSet ( 994assertString ( set . id ), 995challongeMatchItems , 996); 997} else if ( mode === Mode . PARRYGG ) { 998updatedSet = await reportParryggSet ( 999parryggMatchResult , 1000set , 1001isDq ?undefined :getParryggGames (), 1002); 1003} else if ( mode === Mode . OFFLINE_MODE ) { 1004updatedSet = await reportOfflineModeSet ( startggSet ); 1005} 1006if ( reportSettings . alsoCopy || undoSubdir ) { 1007const entrantIdToDisplayNameAndCheckNames = new Map < 1008Id , 1009{ checkNames :Map < string , boolean >; displayName :string } 1010>(); 1011selectedReplaysWithEnforceErrors . forEach (( replay ) => { 1012enforceState . fileNameToPlayerFailures 1013. get ( replay . fileName ) ! 1014. forEach (( playerFailure ) => { 1015const failurePlayer = replay . players . find ( 1016( player ) => player . port === playerFailure . port , 1017) ! ; 1018const displayName = 1019failurePlayer . playerOverrides . displayName || 1020failurePlayer . displayName ; 1021const { entrantId} = failurePlayer . playerOverrides ; 1022if ( entrantId ) { 1023if ( 1024entrantIdToDisplayNameAndCheckNames . has ( entrantId ) 1025) { 1026const { checkNames} = 1027entrantIdToDisplayNameAndCheckNames . get ( 1028entrantId , 1029) ! ; 1030playerFailure . checkNames . forEach (( checkName ) => { 1031checkNames . set ( checkName , true ); 1032}); 1033} else { 1034entrantIdToDisplayNameAndCheckNames . set ( entrantId , { 1035checkNames :new Map ( 1036playerFailure . checkNames . map (( checkName ) => [ 1037checkName , 1038true , 1039]), 1040), 1041 displayName, 1042}); 1043} 1044} 1045}); 1046}); 1047await copyReplays ( 1048updatedSet 1049 ?{ 1050id :updatedSet . id , 1051sggId :updatedSet . sggId , 1052completedAtMs :updatedSet . completedAtMs , 1053stream :updatedSet . stream , 1054} 1055 :undefined , 1056Array . from ( entrantIdToDisplayNameAndCheckNames ). map ( 1057([ entrantId , { checkNames, displayName}]) => ({ 1058 checkNames, 1059 displayName, 1060 entrantId, 1061}), 1062), 1063); 1064} 1065if ( 1066( reportSettings . alsoCopy && 1067reportSettings . alsoDelete && 1068deleteOverrideReason . length === 0 ) || 1069undoSubdir 1070) { 1071await deleteReplays (); 1072} 1073setOpen ( false ); 1074setStartggSet ({ 1075setId :set . id , 1076winnerId :0 , 1077isDQ :false , 1078gameData :[], 1079}); 1080resetGuide (); 1081} catch ( e :any ) { 1082const message = e instanceof Error ?e . message :e ; 1083setReportError ( message ); 1084setReportErrorOpen ( true ); 1085} finally { 1086setReporting ( false ); 1087} 1088}} 1089variant = "contained" 1090> 1091{ reportCopyDeleteButton } 1092</ Button > 1093</ DialogActions > 1094</ Dialog > 1095< Dialog 1096open = { reportErrorOpen } 1097onClose = {() => { 1098setReportErrorOpen ( false ); 1099setReportError ( '' ); 1100}} 1101> 1102< DialogTitle >{ reportCopyDeleteIntent } error! </ DialogTitle > 1103< DialogContent > 1104< DialogContentText >{ reportError }</ DialogContentText > 1105</ DialogContent > 1106< DialogActions > 1107< Button 1108onClick = {() => { 1109setReportErrorOpen ( false ); 1110setReportError ( '' ); 1111}} 1112> 1113Close 1114</ Button > 1115</ DialogActions > 1116</ Dialog > 1117< Dialog 1118open = { enforcerResultOpen } 1119onClose = {() => { 1120setEnforcerResultOpen ( false ); 1121}} 1122> 1123< Stack 1124alignItems = "center" 1125direction = "row" 1126justifyContent = "space-between" 1127marginRight = "24px" 1128> 1129< DialogTitle > 1130{ enforceState . status === EnforceStatus . DONE && 1131'Controller Ruleset Violation Detected' } 1132{ enforceState . status === EnforceStatus . ERROR && 1133'SLP Enforcer Failure' } 1134</ DialogTitle > 1135< Typography variant = "caption" > 1136SLP Enforcer version { enforcerVersion } 1137</ Typography > 1138</ Stack > 1139< DialogContent sx = {{ width :'500px' }}> 1140{ enforceState . status === EnforceStatus . DONE && ( 1141< Stack spacing = "8px" > 1142{ selectedReplaysWithEnforceErrors . map (( selectedReplay ) => ( 1143< Box key = { selectedReplay . fileName }> 1144< Box typography = "caption" > 1145{ stageNames . get ( selectedReplay . stageId )} 1146</ Box > 1147{ enforceState . fileNameToPlayerFailures 1148. get ( selectedReplay . fileName ) ! 1149. map (( enforcePlayerFailure ) => ( 1150< Box key = { enforcePlayerFailure . port } typography = "body2" > 1151{ getDisplayNameFromPlayer ( 1152selectedReplay . players . find ( 1153( player ) => 1154player . port === enforcePlayerFailure . port , 1155), 1156)} 1157: { enforcePlayerFailure . checkNames . join ( ', ' )} 1158</ Box > 1159))} 1160</ Box > 1161))} 1162</ Stack > 1163)} 1164{ enforceState . status === EnforceStatus . ERROR && ( 1165< DialogContentText > 1166{ enforceState . reason instanceof Error 1167 ?enforceState . reason . message 1168 :enforceState . reason . toString ()} 1169</ DialogContentText > 1170)} 1171</ DialogContent > 1172</ Dialog > 1173</> 1174); 1175}