@@ -38,6 +38,7 @@ export default class MatchRunner {
3838 // Match information
3939 private teamA : HTMLSelectElement ;
4040 private teamB : HTMLSelectElement ;
41+ private swapTeamsButton : HTMLButtonElement ;
4142 private profilerEnabled : HTMLInputElement ;
4243 private selectAllMaps : HTMLButtonElement ;
4344 private deselectAllMaps : HTMLButtonElement ;
@@ -119,6 +120,8 @@ export default class MatchRunner {
119120 this . runMatchWithoutViewing = document . createElement ( "button" ) ;
120121 this . killProcs = document . createElement ( "button" ) ;
121122
123+ this . swapTeamsButton = document . createElement ( "button" ) ;
124+
122125 this . profilerEnabled = document . createElement ( "input" ) ;
123126 this . profilerEnabled . type = 'checkbox' ;
124127 this . profilerEnabled . id = 'profiler-enabled' ;
@@ -142,6 +145,14 @@ export default class MatchRunner {
142145 divB . appendChild ( document . createElement ( "br" ) ) ;
143146 div . appendChild ( divB ) ;
144147
148+ // Swap teams button
149+ this . swapTeamsButton . type = "button" ;
150+ this . swapTeamsButton . appendChild ( document . createTextNode ( "Swap Teams" ) ) ;
151+ this . swapTeamsButton . className = "custom-button" ;
152+ this . swapTeamsButton . onclick = this . swapTeams ;
153+ div . appendChild ( this . swapTeamsButton ) ;
154+ div . appendChild ( document . createElement ( "br" ) ) ;
155+
145156 // Profiler enabled checkbox
146157 const divProfiler = document . createElement ( "p" ) ;
147158 divProfiler . appendChild ( this . profilerEnabled ) ;
@@ -270,7 +281,7 @@ export default class MatchRunner {
270281 }
271282 // Found the packages, make the team selectors
272283 if ( packages ) {
273- for ( let player of packages ) {
284+ for ( let player of packages . sort ( ( a , b ) => a . localeCompare ( b ) ) ) {
274285 // Add the player to team A
275286 const optionA = document . createElement ( "option" ) ;
276287 optionA . value = player ;
@@ -286,6 +297,16 @@ export default class MatchRunner {
286297 }
287298 }
288299
300+ private swapTeams = ( ) => {
301+ if ( this . teamA . options . length === 0 || this . teamB . options . length === 0 ) {
302+ return ;
303+ }
304+
305+ const teamAIndex = this . teamA . selectedIndex ;
306+ this . teamA . selectedIndex = this . teamB . selectedIndex ;
307+ this . teamB . selectedIndex = teamAIndex ;
308+ }
309+
289310 /**
290311 * If the scaffold can run a match, add the functionality to the run button
291312 */
0 commit comments