when in doubt make it a property I guess

This commit is contained in:
2025-08-25 22:34:33 -04:00
parent 6c45e7b114
commit 0f015841ff
6 changed files with 91 additions and 53 deletions

View File

@@ -74,38 +74,35 @@ const api = new Elysia({ prefix: "/api" })
},
send,
}) {
console.log(humanKey, "connected");
try {
const table = liveTable<
SimpleConfiguration,
SimpleGameState,
SimpleAction
>(tableKey);
const table = liveTable<
SimpleConfiguration,
SimpleGameState,
SimpleAction
>(tableKey);
table.outputs.playersPresent.onValue((players) =>
send({ players })
);
table.inputs.connectionChanges.emit({
humanKey,
presence: "joined",
});
table.outputs.playersReady.onValue((readys) =>
send({ playersReady: readys })
);
table.outputs.playersPresent.onValue((players) =>
send({ players })
);
combine(
[table.outputs.gameState],
[table.outputs.gameConfig],
(state, config) =>
state &&
config &&
getSimplePlayerView(config, state, humanKey)
).onValue((view) => send({ view }));
table.outputs.playersReady.onValue((readys) =>
send({ playersReady: readys })
);
table.inputs.connectionChanges.emit({
humanKey,
presence: "joined",
});
} catch (err) {
console.error(err);
}
combine(
[table.outputs.gameState],
[table.outputs.gameConfig],
(state, config) =>
state &&
config &&
getSimplePlayerView(config, state, humanKey)
)
.toProperty()
.onValue((view) => send({ view }));
},
response: WsOut,
@@ -144,10 +141,6 @@ const api = new Elysia({ prefix: "/api" })
presence: "left",
});
},
// error(err) {
// console.error("ERROR IN WEBSOCKET", JSON.stringify(err, null, 2));
// },
});
export default api;