Correct the code to work with the new data structure

This commit is contained in:
Oliver Akins 2022-07-25 21:38:05 -06:00
parent 6e51bf7656
commit a36d85ae74
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -11,7 +11,9 @@ import { onMount } from "svelte";
function handleLobbyInfo(data: ILobbyInfo) { function handleLobbyInfo(data: ILobbyInfo) {
if (data.status == Status.Success) { if (data.status == Status.Success) {
players.set(data.players); for (const player of data.players) {
$players[player.id] = player;
}
} else { } else {
console.table(data); console.table(data);
}; };
@ -74,7 +76,7 @@ function toggleOption(e: CustomEvent<string>) {
<div class="sci-fi-box"> <div class="sci-fi-box">
<h2>Players</h2> <h2>Players</h2>
<div class="player-box"> <div class="player-box">
{#each $players as p, i} {#each Object.entries($players) as [id, p], i (id)}
<Player <Player
name="{p.name}" name="{p.name}"
colour="{p.colour}" colour="{p.colour}"