Пример #1
0
        private bool CheckEndRound(NWObject table, float delay = 0.0f)
        {
            // SpeakString("DEBUG: Checking end round.  Player 1 standing? " + game.player1Standing + " Player 2 standing? " + game.player2Standing + " Scores: " + game.player1Score + "/" + game.player2Score);
            // If the game is already over, skip the rest.
            if (table.GetLocalInt("IN_GAME") == 0)
            {
                return(true);
            }

            if (game.player1Score > 20 || game.player2Score > 20 || (game.player1Standing && game.player2Standing))
            {
                game.EndRound();

                if (game.player1Sets == 3)
                {
                    DelayCommand(0.5f + delay, () =>
                    {
                        SpeakString(GetName(game.player1) + " wins, 3 sets to " + game.player2Sets + "!");
                    });
                    PazaakService.EndGame(table, game);
                    table.DeleteLocalInt("IN_GAME");
                }
                else if (game.player2Sets == 3)
                {
                    DelayCommand(1.5f + delay, () =>
                    {
                        SpeakString(GetName(game.player2) + " wins, 3 sets to " + game.player1Sets + "!");
                    });
                    PazaakService.EndGame(table, game);
                    table.DeleteLocalInt("IN_GAME");
                }
                else
                {
                    DelayCommand(1.5f + delay, () =>
                    {
                        SpeakString("New set beginning.  " + GetName(game.player1) + " has won " + game.player1Sets + " sets, " +
                                    GetName(game.player2) + " has won " + game.player2Sets + " sets. " + GetName(game.nextTurn) + " to play.");
                    });
                }

                return(true);
            }

            return(false);
        }