From c305551175783962481895f4408f55c552865b6d Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Wed, 22 Dec 2021 19:39:21 -0700 Subject: [PATCH] Use an each block for option populating --- web-svelte/src/views/lobby/multiplayer.svelte | 85 +++++++++++++------ 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/web-svelte/src/views/lobby/multiplayer.svelte b/web-svelte/src/views/lobby/multiplayer.svelte index cb9374d..4a70f87 100644 --- a/web-svelte/src/views/lobby/multiplayer.svelte +++ b/web-svelte/src/views/lobby/multiplayer.svelte @@ -3,9 +3,55 @@ import OptionInfo from "../../components/modals/OptionInfo.svelte"; import SciFiCheckbox from "../../components/SciFi-Checkbox.svelte"; import SciFiButton from "../../components/SciFi-Button.svelte"; import Player from "../../components/Player.svelte"; +import { myName, hostName } from "../../stores"; function tempButtonHandler() {}; +const gameOptions = [ + { + name: `No Secrets`, + id: `no-secrets`, + active: false, + hidden: false, + }, + { + name: `Warp Gate Activated`, + id: `warp-gate-activated`, + active: true, + hidden: false, + }, + { + name: `Chaos Theory`, + id: `Chaos Theory`, + active: false, + hidden: false, + }, + { + name: `Hardcore`, + id: `hardcore`, + active: false, + hidden: false, + }, + { + name: `Fate`, + id: `fate`, + active: false, + hidden: true, + } +] +$: visibleOptions = gameOptions.filter(x => !x.hidden); + +/** + * What gets called when the host toggles one of the options in the lobby so + * that the other players can see the change happen on their screen. + */ +function toggleOption(e: CustomEvent) { + let option = visibleOptions.find(x => x.id == e.detail); + console.debug(`Toggled option: ${option.name}`); + + // TODO: Send websocket event to server +}; + let optionsModal = false; function toggleOptionsModal() { console.log(`Toggling options modal`) @@ -57,30 +103,17 @@ function toggleOptionsModal() {

Options

- - No Secrets - - - Hardcore Mode - - - Warp Gate Activated! - - - Chaos Theory - + {#each visibleOptions as option} + + {option.name} + + {/each}
@@ -128,8 +161,7 @@ h1 { position: relative; h2 { - margin: 0px; - margin-top: 10px; + margin: 10px 0px; } } @@ -152,7 +184,6 @@ h1 { display: flex; justify-content: space-evenly; flex-wrap: wrap; - } .info-button-container {