Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnecting right after a round finishes leaves round victor unknown #62

Open
mat1jaczyyy opened this issue May 10, 2024 · 2 comments

Comments

@mat1jaczyyy
Copy link
Contributor

mat1jaczyyy commented May 10, 2024

If a player wins a round and then immediately disconnects before the room.game.on("score", event can fire, then victor will be undefined.

/srv/eucannon-test/bot/index.js:453
                .input('winner', room.tournament_match.players.indexOf(victor.user.id) + 1)
                                                                              ^

TypeError: Cannot read properties of undefined (reading 'user')
    at Game.<anonymous> (/srv/eucannon-test/bot/index.js:453:79)
    at Game.emit (node:events:518:28)
    at /srv/eucannon-test/bot/node_modules/tetr.js/dist/ws/commands/game.end.js:60:29
    at Generator.next (<anonymous>)
    at /srv/eucannon-test/bot/node_modules/tetr.js/dist/ws/commands/game.end.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/srv/eucannon-test/bot/node_modules/tetr.js/dist/ws/commands/game.end.js:4:12)
    at default_1 (/srv/eucannon-test/bot/node_modules/tetr.js/dist/ws/commands/game.end.js:14:12)
    at WebSocketManager.<anonymous> (/srv/eucannon-test/bot/node_modules/tetr.js/dist/ws/WebSocketManager.js:187:23)
    at Generator.next (<anonymous>)

In EU Cannon code:

https://github.com/EUCannon/bot/blob/94b0a303cb1f6771537fba8d711d16a07a6913de/index.js#L447-L454

@mat1jaczyyy
Copy link
Contributor Author

tetrjs.issue.62.mp4

@Sup3rFire
Copy link
Member

After some investigation, it seems like the game.score and game.end set the success field of the victor to false, causing tetr.js to not recognize a winner and not defining it instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants