Пример #1
0
        static bool StartGame(S server, Connection conn, Session.Client client, string s)
        {
            lock (server.LobbyInfo)
            {
                if (!client.IsAdmin)
                {
                    server.SendOrderTo(conn, "Message", "Only the host can start the game.");
                    return(true);
                }

                if (server.LobbyInfo.Slots.Any(sl => sl.Value.Required &&
                                               server.LobbyInfo.ClientInSlot(sl.Key) == null))
                {
                    server.SendOrderTo(conn, "Message", "Unable to start the game until required slots are full.");
                    return(true);
                }

                if (!server.LobbyInfo.GlobalSettings.EnableSingleplayer && server.LobbyInfo.NonBotPlayers.Count() < 2)
                {
                    server.SendOrderTo(conn, "Message", server.TwoHumansRequiredText);
                    return(true);
                }

                if (LobbyUtils.InsufficientEnabledSpawnPoints(server.Map, server.LobbyInfo))
                {
                    server.SendOrderTo(conn, "Message", "Unable to start the game until more spawn points are enabled.");
                    return(true);
                }

                server.StartGame();

                return(true);
            }
        }
Пример #2
0
        static void CheckAutoStart(S server)
        {
            lock (server.LobbyInfo)
            {
                var nonBotPlayers = server.LobbyInfo.NonBotPlayers;

                // Are all players and admin (could be spectating) ready?
                if (nonBotPlayers.Any(c => c.State != Session.ClientState.Ready) ||
                    server.LobbyInfo.Clients.First(c => c.IsAdmin).State != Session.ClientState.Ready)
                {
                    return;
                }

                // Does server have at least 2 human players?
                if (!server.LobbyInfo.GlobalSettings.EnableSingleplayer && nonBotPlayers.Count() < 2)
                {
                    return;
                }

                // Are the map conditions satisfied?
                if (server.LobbyInfo.Slots.Any(sl => sl.Value.Required && server.LobbyInfo.ClientInSlot(sl.Key) == null))
                {
                    return;
                }

                if (LobbyUtils.InsufficientEnabledSpawnPoints(server.Map, server.LobbyInfo))
                {
                    return;
                }

                server.StartGame();
            }
        }