@@ -45,6 +45,8 @@ export class HostLobbyModal extends LitElement {
4545 @state ( ) private gameMode : GameMode = GameMode . FFA ;
4646 @state ( ) private teamCount : TeamCountConfig = 2 ;
4747 @state ( ) private bots : number = 400 ;
48+ @state ( ) private spawnImmunity : boolean = false ;
49+ @state ( ) private spawnImmunityDurationMinutes : number | undefined = undefined ;
4850 @state ( ) private infiniteGold : boolean = false ;
4951 @state ( ) private donateGold : boolean = false ;
5052 @state ( ) private infiniteTroops : boolean = false ;
@@ -514,7 +516,7 @@ export class HostLobbyModal extends LitElement {
514516 id ="end-timer-value "
515517 min ="0 "
516518 max ="120 "
517- .value =${ String ( this . maxTimerValue ?? "" ) }
519+ .value =${ String ( this . maxTimerValue ?? 0 ) }
518520 style ="width: 60px; color: black; text-align: right; border-radius: 8px;"
519521 @input=${ this . handleMaxTimerValueChanges }
520522 @keydown=${ this . handleMaxTimerValueKeyDown }
@@ -524,6 +526,47 @@ export class HostLobbyModal extends LitElement {
524526 ${ translateText ( "host_modal.max_timer" ) }
525527 </ div >
526528 </ label >
529+
530+ < label
531+ for ="spawn-immunity "
532+ class ="option-card ${ this . spawnImmunity ? "selected" : "" } "
533+ >
534+ < div class ="checkbox-icon "> </ div >
535+ < input
536+ type ="checkbox "
537+ id ="spawn-immunity "
538+ @change =${ ( e : Event ) => {
539+ const checked = ( e . target as HTMLInputElement ) . checked ;
540+ if ( ! checked ) {
541+ this . spawnImmunityDurationMinutes = undefined ;
542+ }
543+ this . spawnImmunity = checked ;
544+ this . putGameConfig ( ) ;
545+ } }
546+ .checked =${ this . spawnImmunity }
547+ />
548+ ${
549+ this . spawnImmunity === false
550+ ? ""
551+ : html `< input
552+ type ="number "
553+ id ="spawn-immunity-duration "
554+ min ="0 "
555+ max ="120 "
556+ step ="1 "
557+ .value =${ String (
558+ this . spawnImmunityDurationMinutes ?? 0 ,
559+ ) }
560+ style ="width: 60px; color: black; text-align: right; border-radius: 8px;"
561+ @input=${ this . handleSpawnImmunityDurationInput }
562+ @keydown=${ this . handleSpawnImmunityDurationKeyDown }
563+ /> `
564+ }
565+ < div class ="option-card-title ">
566+ < span > ${ translateText ( "host_modal.player_immunity_duration" ) } </ span >
567+ </ div >
568+ </ label >
569+
527570 < hr style ="width: 100%; border-top: 1px solid #444; margin: 16px 0; " />
528571
529572 <!-- Individual disables for structures/weapons -->
@@ -691,6 +734,23 @@ export class HostLobbyModal extends LitElement {
691734 this . putGameConfig ( ) ;
692735 }
693736
737+ private handleSpawnImmunityDurationKeyDown ( e : KeyboardEvent ) {
738+ if ( [ "-" , "+" , "e" , "E" ] . includes ( e . key ) ) {
739+ e . preventDefault ( ) ;
740+ }
741+ }
742+
743+ private handleSpawnImmunityDurationInput ( e : Event ) {
744+ const input = e . target as HTMLInputElement ;
745+ input . value = input . value . replace ( / [ e E + - ] / g, "" ) ;
746+ const value = parseInt ( input . value , 10 ) ;
747+ if ( Number . isNaN ( value ) || value < 0 || value > 120 ) {
748+ return ;
749+ }
750+ this . spawnImmunityDurationMinutes = value ;
751+ this . putGameConfig ( ) ;
752+ }
753+
694754 private handleRandomSpawnChange ( e : Event ) {
695755 this . randomSpawn = Boolean ( ( e . target as HTMLInputElement ) . checked ) ;
696756 this . putGameConfig ( ) ;
@@ -757,6 +817,9 @@ export class HostLobbyModal extends LitElement {
757817 }
758818
759819 private async putGameConfig ( ) {
820+ const spawnImmunityTicks = this . spawnImmunityDurationMinutes
821+ ? this . spawnImmunityDurationMinutes * 60 * 10
822+ : 0 ;
760823 this . dispatchEvent (
761824 new CustomEvent ( "update-game-config" , {
762825 detail : {
@@ -775,6 +838,9 @@ export class HostLobbyModal extends LitElement {
775838 randomSpawn : this . randomSpawn ,
776839 gameMode : this . gameMode ,
777840 disabledUnits : this . disabledUnits ,
841+ spawnImmunityDuration : this . spawnImmunity
842+ ? spawnImmunityTicks
843+ : undefined ,
778844 playerTeams : this . teamCount ,
779845 ...( this . gameMode === GameMode . Team &&
780846 this . teamCount === HumansVsNations
0 commit comments