From 3382bc3795f9b7d5577469c49c11f16dcad80339 Mon Sep 17 00:00:00 2001 From: mytja Date: Sun, 21 Jan 2024 16:16:31 +0100 Subject: [PATCH] fix --- backend/internal/tournament/goroutine.go | 14 +++++++++++++- backend/internal/ws/cards.go | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/internal/tournament/goroutine.go b/backend/internal/tournament/goroutine.go index 38c847d..9f6dffa 100644 --- a/backend/internal/tournament/goroutine.go +++ b/backend/internal/tournament/goroutine.go @@ -345,7 +345,19 @@ func (s *tournamentImpl) RunOrganizer() { s.logger.Debugw("odpiram talon") - for i := range s.games { + for i, g := range s.games { + start := true + for _, v := range g.Players { + if !v.GetBotStatus() && len(v.GetClients()) == 0 { + s.logger.Debugw("preskakujem igro") + start = false + break + } + } + if !start { + // drugače crasha + continue + } s.wsServer.Talon(i) } diff --git a/backend/internal/ws/cards.go b/backend/internal/ws/cards.go index edd3e02..8ac7f0a 100644 --- a/backend/internal/ws/cards.go +++ b/backend/internal/ws/cards.go @@ -226,6 +226,10 @@ func (s *serverImpl) BotCard(gameId string, playing string) { sT := time.Now() card := strings.ReplaceAll(string(s.StockSkisExec("card", playing, gameId)), "\n", "") + if card == "" { + s.logger.Debugw("stockškis failed") + return + } eT := time.Now() player.BroadcastToClients(&messages.Message{