Esempio n. 1
0
        public static void StartNewRound(int _lastWinner, int cardsNeeded)
        {
            // NOTE:(Nathen) "++currentRound" and "currentRound++" are NOT the same thing

            // Check if there is a winner
            bool gameOver = false;

            foreach (ServerClient client in Server.Clients.Values)
            {
                if (client.Points >= cardsNeededToWin)
                {
                    gameOver = true;
                }
            }

            PlayerSubmissions = new Dictionary <int, List <string> >();

            if (gameOver)
            {
                Console.WriteLine($"[Server] GAME OVER! Winner: {_lastWinner}");

                ServerSend.BroadcastGameOver(_lastWinner);
            }
            else
            {
                if ((++currentRound) == 1)
                {
                    // NOTE:(Nathen) This is 'TURN ONE' of the game
                    ServerSend.BroadcastNewRound(currentRound, TurnOrder[0], lastCardCzar, NO_WINNER, cardsNeeded, currentQuestion, "[Server] First Round of the Game!");
                }
                else
                {
                    lastCardCzar = CurrentTurn;

                    // The Properties "NextTurn" Auto Increments the turn index and returns the ID for the next card czar
                    int nextTurnID = NextTurn;

                    // This was an error round
                    if (_lastWinner == NO_WINNER)
                    {
                        // Forced round
                        ServerSend.BroadcastNewRound(currentRound, nextTurnID, lastCardCzar, NO_WINNER, cardsNeeded, currentQuestion, $"[Server] A New Round was Forced!\n[Server] Round {currentRound}");
                    }
                    else
                    {
                        // Normal Round
                        ServerSend.BroadcastNewRound(currentRound, nextTurnID, lastCardCzar, _lastWinner, cardsNeeded, currentQuestion, $"[Server] Round | {currentRound}");
                    }
                }
            }
        }