Make the lobby more compatible with the colour/ship objects

This commit is contained in:
Oliver Akins 2022-03-12 23:14:42 -06:00
parent 6f38c7e2a3
commit dd5a1e8cb9
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99
2 changed files with 8 additions and 7 deletions

View file

@ -2,9 +2,10 @@
import SciFiButton from "./SciFi-Button.svelte"; import SciFiButton from "./SciFi-Button.svelte";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
import { myName, isHost } from "../stores"; import { myName, isHost } from "../stores";
import type { IColour } from "common";
export let name: string; export let name: string;
export let colour: string; export let colour: IColour;
const emit = createEventDispatcher(); const emit = createEventDispatcher();
@ -22,11 +23,11 @@ let canLeave = $isHost || name == $myName;
<!-- The player's change Colour button --> <!-- The player's change Colour button -->
{#if $myName == name} {#if $myName == name}
<SciFiButton <SciFiButton
background="{colour}" background="{colour.hex}"
on:click={changeColour} on:click={changeColour}
height="60px" height="60px"
width="60px" width="60px"
hoverBackground="{colour}" hoverBackground="{colour.hex}"
> >
<div style="display: flex; align-items: center; justify-content: center;"> <div style="display: flex; align-items: center; justify-content: center;">
<img <img

View file

@ -16,8 +16,8 @@ let player = $players.find(p => p.name == $myName);
$: myColour = player.colour; $: myColour = player.colour;
$: takenColours = $players.map(p => p.colour); $: takenColours = $players.map(p => p.colour);
var selectedColour = player.colour; var selectedColour = player.colour.hex;
var selectedShip = player.ship; var selectedShip = player.ship.id;
var error = null; var error = null;
function saveShipDesign() { function saveShipDesign() {
@ -74,8 +74,8 @@ function saveShipDesign() {
<option <option
value="{c.hex}" value="{c.hex}"
disabled="{ disabled="{
c.hex != myColour c.hex != myColour.hex
&& takenColours.includes(c.hex) && takenColours.includes(c)
}" }"
> >
{c.name} {c.name}