bug fixes
This commit is contained in:
@@ -12,7 +12,7 @@ import { transform } from "./kefir-extension";
|
||||
|
||||
export const WsOut = t.Object({
|
||||
players: t.Optional(t.Array(t.String())),
|
||||
playersReady: t.Optional(t.Record(t.String(), t.String())),
|
||||
playersReady: t.Optional(t.Record(t.String(), t.Boolean())),
|
||||
view: t.Optional(t.Any()),
|
||||
});
|
||||
export type TWsOut = typeof WsOut.static;
|
||||
@@ -60,7 +60,6 @@ export const liveTable = <GameConfig, GameState, GameAction>(key: string) => {
|
||||
quits: Bus(),
|
||||
};
|
||||
const { connectionChanges, readys, actions, quits } = inputs;
|
||||
|
||||
// =======
|
||||
|
||||
const playersPresent = connectionChanges
|
||||
@@ -97,7 +96,11 @@ export const liveTable = <GameConfig, GameState, GameAction>(key: string) => {
|
||||
);
|
||||
|
||||
const gameStarts = playersReady
|
||||
.filter((pr) => Object.values(pr).every((ready) => ready))
|
||||
.filter(
|
||||
(pr) =>
|
||||
Object.values(pr).length > 0 &&
|
||||
Object.values(pr).every((ready) => ready)
|
||||
)
|
||||
.map((_) => null);
|
||||
|
||||
const gameConfig = playersPresent.map((players) => ({
|
||||
@@ -147,9 +150,11 @@ export const liveTable = <GameConfig, GameState, GameAction>(key: string) => {
|
||||
|
||||
// cleanup
|
||||
tables[key].outputs.playersPresent
|
||||
.debounce(30000)
|
||||
.debounce(30000, { immediate: false })
|
||||
.filter((players) => players.length === 0)
|
||||
.skip(1)
|
||||
.onValue((_) => {
|
||||
console.log("DELETING LIVE TABLE");
|
||||
delete tables[key];
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user