Exemplo n.º 1
0
        private void tas_BattleMapChanged(object sender, TasEventArgs e)
        {
            if (config.DisplayMapLink)
            {
                SayBattle("maplink: " + linker.GetMapBounceLink(tas.GetBattle().Map.Name));
            }
            foreach (UserBattleStatus p in tas.GetBattle().Users)
            {
                //ring all people that host changed the map
                tas.Ring(p.name);
            }
            Battle b       = tas.GetBattle();
            string mapName = b.Map.ArchiveName.ToLower();

            if (MapBoxes.ContainsKey(mapName))
            {
                for (int i = 0; i < b.Rectangles.Count; ++i)
                {
                    tas.RemoveBattleRectangle(i);
                }
                Dictionary <int, BattleRect> dict = MapBoxes[mapName];
                foreach (KeyValuePair <int, BattleRect> v in dict)
                {
                    tas.AddBattleRectangle(v.Key, v.Value);
                }
            }
        }
Exemplo n.º 2
0
        private void spring_SpringExited(object sender, EventArgs e)
        {
            tas.ChangeLock(false);
            var b = tas.GetBattle();

            foreach (var s in toNotify)
            {
                if (b != null && b.ContainsUser(s))
                {
                    tas.Ring(s);
                }
                tas.Say(TasClient.SayPlace.User, s, "** Game just ended, join me! **", false);
            }
            toNotify.Clear();
        }
Exemplo n.º 3
0
        void spring_SpringExited(object sender, EventArgs e)
        {
            StopVote();
            tas.ChangeMyUserStatus(false, false);
            Battle b = tas.MyBattle;

            foreach (string s in toNotify)
            {
                if (b != null && b.Users.ContainsKey(s))
                {
                    tas.Ring(SayPlace.BattlePrivate, s);
                }
                tas.Say(SayPlace.User, s, "** Game just ended, join me! **", false);
            }
            toNotify.Clear();

            if (SpawnConfig == null && DateTime.Now.Subtract(spring.GameStarted).TotalMinutes > 5)
            {
                ServerVerifyMap(true);
            }
        }
Exemplo n.º 4
0
        private void spring_SpringExited(object sender, EventArgs e)
        {
            tas.ChangeLock(false);
            var b = tas.GetBattle();

            foreach (var s in toNotify)
            {
                if (b != null && b.ContainsUser(s))
                {
                    tas.Ring(s);
                }
                tas.Say(TasClient.SayPlace.User, s, "** Game just ended, join me! **", false);
            }
            toNotify.Clear();
            if (!string.IsNullOrEmpty(delayedModChange))
            {
                string mod = delayedModChange;
                delayedModChange = null;
                SayBattle("Updating to latest mod version: " + mod);
                ComRehost(TasSayEventArgs.Default, new[] { mod });
            }
        }
Exemplo n.º 5
0
        void spring_SpringExited(object sender, EventArgs e)
        {
            StopVote();
            lockedUntil = DateTime.MinValue;
            tas.ChangeLock(false);
            tas.ChangeMyUserStatus(false, false);
            Battle b = tas.MyBattle;

            foreach (string s in toNotify)
            {
                if (b != null && b.Users.Any(x => x.Name == s))
                {
                    tas.Ring(s);
                }
                tas.Say(TasClient.SayPlace.User, s, "** Game just ended, join me! **", false);
            }
            toNotify.Clear();

            if (SpawnConfig == null && DateTime.Now.Subtract(spring.GameStarted).TotalMinutes > 5)
            {
                ServerVerifyMap(true);
            }
        }
        public MatchMakerQueue(AutoHost ah)
        {
            this.ah = ah;
            ah.Commands.Commands.RemoveAll(x => !allowedCommands.Contains(x.Name));

            tas = ah.tas;

            tas.BattleOpened += (sender, args) =>
            {
                starting = false;
                UpdateCount();
                StopIfCountLow();
                lastCount = count;
            };

            tas.BattleUserJoined += (sender, args) =>
            {
                if (tas.MyBattleID != args.BattleID) return;
                tas.Say(SayPlace.BattlePrivate,
                    args.UserName,
                    string.Format("Hi {0}, you are {1}. in the queue", args.UserName, tas.MyBattle.NonSpectatorCount),
                    true);
            };

            tas.BattleUserLeft += (sender, args) =>
            {
                if (tas.MyBattleID != args.BattleID) return;

                UpdateCount();
                StopIfCountLow();
                lastCount = count;
            };

            tas.BattleUserStatusChanged += (sender, args) =>
            {
                UpdateCount();
                if (count != lastCount) // user count changed
                {
                    if (count > lastCount) // users added
                    {
                        if (count >= ah.config.MinToJuggle) // enough to start
                        {
                            if (!starting) // start fresh
                            {
                                startingFrom = DateTime.Now;
                                scheduledStart = startingFrom.AddSeconds(initialDelay); // start in one minute
                                starting = true;
                                foreach (var user in tas.MyBattle.Users.Keys) tas.Ring(SayPlace.BattlePrivate, user);
                            }
                            else // postpone
                            {
                                DateTime postpone = scheduledStart.AddSeconds(newJoinerDelay);
                                DateTime deadline = startingFrom.AddSeconds(maxDelay);
                                if (postpone > deadline) scheduledStart = deadline;
                                else scheduledStart = postpone;
                            }
                            tas.Say(SayPlace.Battle,
                                "",
                                string.Format("Queue starting in {0}s", Math.Round(scheduledStart.Subtract(DateTime.Now).TotalSeconds)),
                                true);
                        }
                        else // not enough to start
                            tas.Say(SayPlace.Battle, "", string.Format("Queue needs {0} more people", ah.config.MinToJuggle - count), true);
                    }
                    else // users removed
                        StopIfCountLow();

                    lastCount = count;
                }
            };

            var timer = new Timer();
            timer.Interval = 1000;
            timer.AutoReset = true;
            timer.Elapsed += (sender, args) =>
            {
                if (starting && DateTime.Now >= scheduledStart)
                {
                    starting = false;

                    var teams = BuildTeams();
                    if (teams == null) tas.Say(SayPlace.Battle, "", "Queue cannot start yet because of skill differences", true);
                    else
                    {
                        var spectators =
                            tas.MyBattle.Users.Values.Where(x => x.IsSpectator && x.Name != tas.MyBattle.Founder.Name && x.SyncStatus == SyncStatuses.Synced).ToList();

                        foreach (var t in teams)
                        {
                            CreateSlave(t, spectators);
                            spectators = null;
                        }
                    }
                }

            };

            timer.Start();
        }
        public MatchMakerQueue(AutoHost ah)
        {
            this.ah = ah;
            ah.Commands.Commands.RemoveAll(x => !allowedCommands.Contains(x.Name));

            tas = ah.tas;

            tas.BattleOpened += (sender, args) =>
            {
                starting = false;
                UpdateCount();
                StopIfCountLow();
                lastCount = count;
            };

            tas.BattleUserJoined += (sender, args) =>
            {
                if (tas.MyBattleID != args.BattleID)
                {
                    return;
                }
                tas.Say(SayPlace.BattlePrivate,
                        args.UserName,
                        string.Format("Hi {0}, you are {1}. in the queue", args.UserName, tas.MyBattle.NonSpectatorCount),
                        true);
            };

            tas.BattleUserLeft += (sender, args) =>
            {
                if (tas.MyBattleID != args.BattleID)
                {
                    return;
                }

                UpdateCount();
                StopIfCountLow();
                lastCount = count;
            };

            tas.BattleUserStatusChanged += (sender, args) =>
            {
                UpdateCount();
                if (count != lastCount)                     // user count changed
                {
                    if (count > lastCount)                  // users added
                    {
                        if (count >= ah.config.MinToJuggle) // enough to start
                        {
                            if (!starting)                  // start fresh
                            {
                                startingFrom   = DateTime.Now;
                                scheduledStart = startingFrom.AddSeconds(initialDelay); // start in one minute
                                starting       = true;
                                foreach (var user in tas.MyBattle.Users.Keys)
                                {
                                    tas.Ring(SayPlace.BattlePrivate, user);
                                }
                            }
                            else // postpone
                            {
                                DateTime postpone = scheduledStart.AddSeconds(newJoinerDelay);
                                DateTime deadline = startingFrom.AddSeconds(maxDelay);
                                if (postpone > deadline)
                                {
                                    scheduledStart = deadline;
                                }
                                else
                                {
                                    scheduledStart = postpone;
                                }
                            }
                            tas.Say(SayPlace.Battle,
                                    "",
                                    string.Format("Queue starting in {0}s", Math.Round(scheduledStart.Subtract(DateTime.Now).TotalSeconds)),
                                    true);
                        }
                        else // not enough to start
                        {
                            tas.Say(SayPlace.Battle, "", string.Format("Queue needs {0} more people", ah.config.MinToJuggle - count), true);
                        }
                    }
                    else // users removed
                    {
                        StopIfCountLow();
                    }

                    lastCount = count;
                }
            };

            var timer = new Timer();

            timer.Interval  = 1000;
            timer.AutoReset = true;
            timer.Elapsed  += (sender, args) =>
            {
                if (starting && DateTime.Now >= scheduledStart)
                {
                    starting = false;

                    var teams = BuildTeams();
                    if (teams == null)
                    {
                        tas.Say(SayPlace.Battle, "", "Queue cannot start yet because of skill differences", true);
                    }
                    else
                    {
                        var spectators =
                            tas.MyBattle.Users.Values.Where(x => x.IsSpectator && x.Name != tas.MyBattle.Founder.Name && x.SyncStatus == SyncStatuses.Synced).ToList();

                        foreach (var t in teams)
                        {
                            CreateSlave(t, spectators);
                            spectators = null;
                        }
                    }
                }
            };

            timer.Start();
        }