lijim / monks-and-mages

Monks and Mages is a TCG-game built on React and socket.io
https://www.monksandmages.com
MIT License
17 stars 0 forks source link

Bug: Games with unauthenticated players can't be rejoined #438

Open lijim opened 1 year ago

lijim commented 1 year ago

Right now rejoin works fine if there are two or more players that are logged in, but if one or more players don't have logins, the game doesn't handle rejoin functionality as expected, instead booting both players out.

The suspected code is the code for calculating if a whole room is abandoned:

const isEntireRoomDisconnected = (room: DetailedRoomWithBoard): boolean => {
        if (!room) {
            return false;
        }
        const allSessions = findAllSessions();
        const { players } = room;
        return players.every(
            (player) =>
                !allSessions.find((session) => session.username === player)
                    ?.connected
        );
    };