make sure games end when there was just one player

This commit is contained in:
whosit 2024-11-28 19:05:33 +03:00
parent ff31a5ed9e
commit 830bcddb8c

View File

@ -20,6 +20,7 @@ yl_snowball.AFK_TIME = 45
local active_games = {}
yl_snowball.active_games = active_games
local games_by_player = yl_snowball.games_by_player or {}
yl_snowball.games_by_player = games_by_player
@ -171,7 +172,7 @@ function Game:add_player(player_name, game_player)
games_by_player[player_name] = self
end
-- Do nothing here: player merged their old scores from the
-- game there weren't active in
-- game where they weren't active in
else
if (not game_player) or (not game_player.active) then
game_player = GamePlayer(player_name)
@ -182,7 +183,7 @@ function Game:add_player(player_name, game_player)
-- this is a new player, increase player count
self.player_num = self.player_num + 1
end
end
end
function Game:get_player(player_name)
@ -236,13 +237,13 @@ function Game:stop()
self:get_info_string(),
}
if self.player_num > 1 then
for player_name, player in pairs(self.players) do
if games_by_player[player_name] then
for player_name, player in pairs(self.players) do
if games_by_player[player_name] then
if self.player_num > 1 then
core.chat_send_player(player_name, table.concat(lines, "\n"))
player:quit()
games_by_player[player_name] = nil
end
player:quit()
games_by_player[player_name] = nil
end
end