コード例 #1
0
        protected virtual async Task OnDedicatedExited(SpringBattleContext springBattleContext)
        {
            StopVote();
            IsInGame     = false;
            RunningSince = null;

            var debriefingMessage = BattleResultHandler.SubmitSpringBattleResult(springBattleContext, server);

            Debriefings.Add(debriefingMessage);

            await server.Broadcast(Users.Keys, debriefingMessage);

            await server.Broadcast(server.ConnectedUsers.Keys, new BattleUpdate()
            {
                Header = GetHeader()
            });

            foreach (var s in toNotify)
            {
                await
                server.GhostSay(new Say()
                {
                    User       = GlobalConst.NightwatchName,
                    Text       = $"** {FounderName} 's {Title} just ended, join me! **",
                    Target     = s,
                    IsEmote    = true,
                    Place      = SayPlace.User,
                    Ring       = true,
                    AllowRelay = false
                });
            }

            toNotify.Clear();
            await CheckCloseBattle();
        }
コード例 #2
0
        protected virtual async Task OnDedicatedExited(SpringBattleContext springBattleContext)
        {
            StopVote();
            IsInGame     = false;
            RunningSince = null;
            EndedSince   = DateTime.UtcNow;

            var debriefingMessage = BattleResultHandler.SubmitSpringBattleResult(springBattleContext, server);

            Debriefings.Add(debriefingMessage);

            await server.Broadcast(Users.Keys, debriefingMessage);

            await server.Broadcast(server.ConnectedUsers.Keys, new BattleUpdate()
            {
                Header = GetHeader()
            });

            foreach (var s in toNotify)
            {
                await
                server.GhostSay(new Say()
                {
                    User       = GlobalConst.NightwatchName,
                    Text       = $"** {FounderName} 's {Title} just ended, join me! **",
                    Target     = s,
                    IsEmote    = true,
                    Place      = SayPlace.User,
                    Ring       = true,
                    AllowRelay = false
                });
            }

            toNotify.Clear();

            var playingEligibleUsers = server.MatchMaker.GetEligibleQuickJoinPlayers(Users.Values.Where(x => !x.LobbyUser.IsAway && !x.IsSpectator).Select(x => server.ConnectedUsers[x.Name]).ToList());

            if (playingEligibleUsers.Count() >= InviteMMPlayers)   //Make sure there are enough eligible users for a battle to be likely to happen

            //put all users into MM queue to suggest battles
            {
                var teamsQueues    = server.MatchMaker.PossibleQueues.Where(x => x.Mode == AutohostMode.Teams).ToList();
                var availableUsers = Users.Values.Where(x => !x.LobbyUser.IsAway).Select(x => server.ConnectedUsers[x.Name]).ToList();
                await server.MatchMaker.MassJoin(availableUsers, teamsQueues);
            }


            if (IsAutohost)
            {
                await RunCommandDirectly <CmdMap>(null);

                discussionTimer.Interval = (DiscussionTime + 1) * 1000;
                discussionTimer.Start();
            }
            await CheckCloseBattle();
        }
コード例 #3
0
        protected virtual async Task OnDedicatedExited(SpringBattleContext springBattleContext)
        {
            StopVote();
            IsInGame        = false;
            RunningSince    = null;
            BlockPollsUntil = DateTime.UtcNow.AddSeconds(DiscussionSeconds);

            bool result = BattleResultHandler.SubmitSpringBattleResult(springBattleContext, server, (debriefing) =>
            {
                Debriefings.Add(debriefing);
                server.Broadcast(springBattleContext.ActualPlayers.Select(x => x.Name), debriefing);
                Trace.TraceInformation("Battle ended: Sent out debriefings for B" + debriefing.ServerBattleID);
            });

            await server.Broadcast(server.ConnectedUsers.Keys, new BattleUpdate()
            {
                Header = GetHeader()
            });

            foreach (var s in toNotify)
            {
                await
                server.GhostSay(new Say()
                {
                    User       = GlobalConst.NightwatchName,
                    Text       = $"** {FounderName} 's {Title} just ended, join me! **",
                    Target     = s,
                    IsEmote    = true,
                    Place      = SayPlace.User,
                    Ring       = true,
                    AllowRelay = false
                });
            }

            toNotify.Clear();

            var playingEligibleUsers = server.MatchMaker.GetEligibleQuickJoinPlayers(Users.Values.Where(x => !x.LobbyUser.IsAway && !x.IsSpectator && x.Name != null).Select(x => server.ConnectedUsers[x.Name]).ToList());

            if (playingEligibleUsers.Count() >= InviteMMPlayers)
            { //Make sure there are enough eligible users for a battle to be likely to happen
                //put all users into MM queue to suggest battles
                var teamsQueues    = server.MatchMaker.PossibleQueues.Where(x => x.Mode == AutohostMode.Teams).ToList();
                var availableUsers = Users.Values.Where(x => !x.LobbyUser.IsAway && x.Name != null).Select(x => server.ConnectedUsers[x.Name]).ToList();
                await server.MatchMaker.MassJoin(availableUsers, teamsQueues);

                DiscussionSeconds = MatchMaker.TimerSeconds + 2;
            }
            else
            {
                DiscussionSeconds = 5;
            }
            BlockPollsUntil = DateTime.UtcNow.AddSeconds(DiscussionSeconds);


            if (IsAutohost || (!Users.ContainsKey(FounderName) || Users[FounderName].LobbyUser?.IsAway == true) && Mode != AutohostMode.None && Mode != AutohostMode.Planetwars && !IsPassworded)
            {
                if (!result)
                {
                    //Game was aborted/exited/invalid, allow manual commands
                    BlockPollsUntil = DateTime.UtcNow;
                }
                else
                {
                    //Initiate discussion time, then map vote, then start vote
                    discussionTimer.Interval = (DiscussionSeconds - 1) * 1000;
                    discussionTimer.Start();
                }
            }
            await CheckCloseBattle();
        }