Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ps/handlers/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ export function interfaceHandler(message: PSMessage) {
if (!game) return; // Don't put any errors here! People should be able to close games that don't exist, like ones that ended

const user = message.author.id;
if (game.hasPlayer(user)) {
const player = Object.values(game.players).find(p => p.id === user);
if (game.hasPlayer(user) && player && !player.out) {
message.reply(game.$T('GAME.CANNOT_LEAVE', { prefix, game: game.meta.id }));
return game.update(user);
}
if (game.spectators.includes(user)) {
if (game.spectators.includes(user) || (player && player.out)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh oops

Issue here is that a player who's out won't be in spectators either. We might need to do something like:

  • Players are only sent HTML if player.out is not true
  • Players that should keep spectating even upon being out (eg: Chain Reaction) should be moved to game.spectators instead (and stuff like rejoin will have to be rechecked once to make sure player.out === true && spectators.includes(player) conditions are handled

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to remove the line here now

Also need to disable auto-updates for players that are out

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the line but not sure what you mean by the auto-updates? Since they become spectators shouldn't they also keep getting updates sent to them

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
(The second case is handled correctly but not the first, so if anything happens that tries to fire a rejoin, they'll be rendered as a full player)

game.spectators.remove(user);
message.reply(
game.$T('GAME.NO_LONGER_WATCHING', {
Expand Down