diff --git a/src/client/ClientGameRunner.ts b/src/client/ClientGameRunner.ts index 2587af3de..26de903ae 100644 --- a/src/client/ClientGameRunner.ts +++ b/src/client/ClientGameRunner.ts @@ -59,6 +59,7 @@ export interface LobbyConfig { difficulty: Difficulty | null; disableBots: boolean | null; disableNPCs: boolean | null; + creativeMode: boolean | null; } export function joinLobby( @@ -82,6 +83,7 @@ export function joinLobby( difficulty: lobbyConfig.difficulty, disableBots: lobbyConfig.disableBots, disableNPCs: lobbyConfig.disableNPCs, + creativeMode: lobbyConfig.creativeMode, }; } diff --git a/src/client/HostLobbyModal.ts b/src/client/HostLobbyModal.ts index 28dc377d7..0a37a2410 100644 --- a/src/client/HostLobbyModal.ts +++ b/src/client/HostLobbyModal.ts @@ -11,6 +11,7 @@ export class HostLobbyModal extends LitElement { @state() private selectedDiffculty: Difficulty = Difficulty.Medium; @state() private disableNPCs = false; @state() private disableBots = false; + @state() private creativeMode = false; @state() private lobbyId = ""; @state() private copySuccess = false; @state() private players: string[] = []; @@ -183,6 +184,14 @@ export class HostLobbyModal extends LitElement { /> +
Players: ${this.players.join(", ")}
@@ -211,6 +220,7 @@ export class HostLobbyModal extends LitElement { difficulty: this.selectedDiffculty, disableBots: this.disableBots, disableNPCs: this.disableNPCs, + creativeMode: this.creativeMode, }, bubbles: true, composed: true, @@ -258,6 +268,12 @@ export class HostLobbyModal extends LitElement { this.putGameConfig(); } + private async handleCreativeModeChange(e: Event) { + this.creativeMode = Boolean((e.target as HTMLInputElement).checked); + consolex.log(`updating creative mode to ${this.creativeMode}`); + this.putGameConfig(); + } + private async putGameConfig() { const response = await fetch(`/private_lobby/${this.lobbyId}`, { method: "PUT", @@ -269,6 +285,7 @@ export class HostLobbyModal extends LitElement { difficulty: this.selectedDiffculty, disableBots: this.disableBots, disableNPCs: this.disableNPCs, + creativeMode: this.creativeMode, }), }); } diff --git a/src/client/Main.ts b/src/client/Main.ts index 542588b68..3b36a7fe4 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -115,6 +115,7 @@ class Client { difficulty: event.detail.difficulty, disableBots: event.detail.disableBots, disableNPCs: event.detail.disableNPCs, + creativeMode: event.detail.creativeMode, }, () => this.joinModal.close() ); diff --git a/src/client/SinglePlayerModal.ts b/src/client/SinglePlayerModal.ts index 9645b25f3..fdb03c28b 100644 --- a/src/client/SinglePlayerModal.ts +++ b/src/client/SinglePlayerModal.ts @@ -11,6 +11,7 @@ export class SinglePlayerModal extends LitElement { @state() private selectedDifficulty: Difficulty = Difficulty.Medium; @state() private disableNPCs = false; @state() private disableBots = false; + @state() private creativeMode = false; static styles = css` .modal-overlay { @@ -134,6 +135,15 @@ export class SinglePlayerModal extends LitElement {