Beispiel #1
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful");
                    ah.ComKickSpec(e, new string[] { stateAfter ? "1" : "0" });
                }
                else
                {
                    ah.SayBattle("not enough votes to " + (stateAfter ? "ENABLE" : "DISABLE") + " kickspec");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public bool Init(TasSayEventArgs e, string[] words)
        {
            if (words.Length == 0)
            {
                if (ah.BossName == "")
                {
                    ah.Respond(e, "there is currently no boss to remove");
                    return(false);
                }
                else
                {
                    player = "";
                    ah.SayBattle("Do you want to remove current boss " + ah.BossName + "? !vote 1 = yes, !vote 2 = no");
                    return(true);
                }
            }

            string[] players;
            int[]    indexes;
            if (AutoHost.FilterUsers(words, tas, spring, out players, out indexes) > 0)
            {
                player = players[0];
                ah.SayBattle("Do you want to elect " + player + " for the boss? !vote 1 = yes, !vote 2 = no");
                return(true);
            }
            else
            {
                AutoHost.Respond(tas, spring, e, "Cannot find such player");
                return(false);
            }
        }
Beispiel #3
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - rehosting");

                    ah.ComRehost(e, new string[] { modname });
                }
                else
                {
                    ah.SayBattle("not enough votes");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - appling preset " + presetName);
                    ah.presets[presetId].Apply(tas, ah.ladder);
                }
                else
                {
                    ah.SayBattle("not enough votes for preset");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - kicking " + player);
                    ah.ComKick(TasSayEventArgs.Default, new string[] { player });
                }
                else
                {
                    ah.SayBattle("not enough votes, player stays");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        public AbstractPoll(TasClient tas, Spring spring, AutoHost ah)
        {
            this.tas    = tas;
            this.spring = spring;
            this.ah     = ah;

            initialUserCount = 0;
            Battle b = tas.GetBattle();

            if (b != null)
            {
                foreach (UserBattleStatus us in b.Users)
                {
                    if (us.name != tas.UserName)
                    {
                        users.Add(us.name);
                        votes.Add(0);
                        if (!us.IsSpectator)
                        {
                            initialUserCount++;
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - changing map to " + map);
                    tas.ChangeMap(spring.UnitSync.MapList[map]);
                }
                else
                {
                    ah.SayBattle("not enough votes, map stays");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        public VotePlanet(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
        {
            this.tas    = tas;
            this.spring = spring;
            this.ah     = ah;

            var pw   = Program.main.PlanetWars;
            var fact = pw.GetOffensiveFaction();

            faction = fact.Name;

            users.Clear();
            votes.Clear();

            initialUserCount = 0;
            Battle b = tas.GetBattle();

            if (b != null)
            {
                foreach (UserBattleStatus us in b.Users)
                {
                    if (us.name != tas.UserName && !us.IsSpectator && pw.GetPlayerInfo(us.name).FactionName == faction)
                    {
                        users.Add(us.name);
                        votes.Add(0);
                        initialUserCount++;
                    }
                }
            }
        }
        public PlanetWarsHandler(string host, int port, AutoHost autoHost, TasClient tas, MainConfig config)
        {
            this.autoHost = autoHost;
            this.tas = tas;
            this.host = host;
            account = new AuthInfo(config.AccountName, config.PlanetWarsServerPassword);

            server = (ISpringieServer) Activator.GetObject(typeof (ISpringieServer), String.Format("tcp://{0}:{1}/IServer", host, port));
            // fill factions for channel monitoring and join channels
            planetWarsChannels = new List<string>();
            var factions = server.GetFactions(account);
            foreach (var fact in factions) {
                string name = fact.Name.ToLower();
                planetWarsChannels.Add(name);
                if (!config.JoinChannels.Contains(name)) {
                    var list = new List<string>(config.JoinChannels);
                    list.Add(name);
                    config.JoinChannels = list.ToArray();
                    if (tas != null && tas.IsConnected && tas.IsLoggedIn) tas.JoinChannel(name);
                }
            }
            timer.Interval = 2000;
            timer.Elapsed += timer_Elapsed;
            timer.AutoReset = true;
            timer.Start();
        }
Beispiel #10
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - appling options " + wordFormat);
                    tas.SetScriptTag(scriptTagsFormat);
                }
                else
                {
                    ah.SayBattle("not enough votes for setoptions");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #11
0
        public bool Init(TasSayEventArgs e, string[] words)
        {
            if (!spring.IsRunning)
            {
                ah.SayBattle("Do you want to force start game? !vote 1 = yes, !vote 2 = no");

                // only smallest ally team can vote
                var b        = tas.GetBattle();
                var grouping = b.Users.Where(u => !u.IsSpectator).GroupBy(u => u.AllyNumber).OrderBy(g => g.Count()).ToList();
                if (grouping.Count() == 2)
                {
                    allowedAlly      = grouping[0].Key;
                    initialUserCount = grouping[0].Count();
                }
                else
                {
                    allowedAlly = -1;
                }

                return(true);
            }
            else
            {
                AutoHost.Respond(tas, spring, e, "battle already started");
                return(false);
            }
        }
Beispiel #12
0
    public BanList(AutoHost ah, TasClient tas)
    {
      this.tas = tas;
      this.ah = ah;

      tas.BattleUserIpRecieved += new EventHandler<TasEventArgs>(tas_BattleUserIpRecieved);
      tas.BattleUserJoined += new EventHandler<TasEventArgs>(tas_BattleUserJoined);
    }
Beispiel #13
0
        public BanList(AutoHost ah, TasClient tas)
        {
            this.tas = tas;
            this.ah  = ah;

            tas.BattleUserIpRecieved += tas_BattleUserIpRecieved;
            tas.BattleUserJoined     += tas_BattleUserJoined;
        }
Beispiel #14
0
    public BanList(AutoHost ah, TasClient tas)
    {
      this.tas = tas;
      this.ah = ah;

      tas.BattleUserIpRecieved += tas_BattleUserIpRecieved;
      tas.BattleUserJoined += tas_BattleUserJoined;
    }
Beispiel #15
0
        public BanList(AutoHost ah, TasClient tas)
        {
            this.tas = tas;
            this.ah  = ah;

            tas.BattleUserIpRecieved += new EventHandler <TasEventArgs>(tas_BattleUserIpRecieved);
            tas.BattleUserJoined     += new EventHandler <TasEventArgs>(tas_BattleUserJoined);
        }
 void CheckAutoCloseSlave(bool exited, AutoHost slave)
 {
     if (exited && slave.tas.MyBattle.NonSpectatorCount < ah.config.MinToJuggle && !slave.spring.IsRunning)
     {
         foreach (var p in slave.tas.MyBattle.Users.Values.Where(x => !x.IsSpectator && x.Name != slave.tas.MyBattle.Founder.Name))
         {
             slave.tas.ForceJoinBattle(p.Name, tas.MyBattleID);
         }
         Program.main.StopAutohost(slave);
     }
 }
Beispiel #17
0
        internal static int FilterPresets(string[] words, AutoHost autohost, out string[] vals, out int[] indexes)
        {
            string[] temp = new string[autohost.presets.Count];
            int      cnt  = 0;

            foreach (Preset p in autohost.presets)
            {
                temp[cnt++] = p.Name + " --> " + p.Description;
            }
            return(Filter(temp, words, out vals, out indexes));
        }
Beispiel #18
0
 public bool Init(TasSayEventArgs e, string[] words)
 {
     if (!spring.IsRunning)
     {
         ah.SayBattle("Do you want to force start game? !vote 1 = yes, !vote 2 = no");
         return(true);
     }
     else
     {
         AutoHost.Respond(tas, spring, e, "battle already started");
         return(false);
     }
 }
Beispiel #19
0
 public bool Init(TasSayEventArgs e, string[] words)
 {
     if (spring.IsRunning)
     {
         ah.SayBattle("Do you want to exit this game? !vote 1 = yes, !vote 2 = no");
         return(true);
     }
     else
     {
         AutoHost.Respond(tas, spring, e, "game not running");
         return(false);
     }
 }
Beispiel #20
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;
            var pw = Program.main.PlanetWars;


            if (e.UserName != "")
            {
                // this is needed due to "timeout" hackthing with vote
                var info = pw.GetPlayerInfo(e.UserName);

                if (info == null || info.FactionName != faction)
                {
                    AutoHost.Respond(tas, spring, e, string.Format("{0}, it's not your faction's turn", e.UserName));
                    return(false);
                }

                if (!RegisterVote(e, words, out vote))
                {
                    AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                    return(false);
                }
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - changing planet to " + planet);
                    var sel = pw.GetAttackOptions().Find((p) => p.Name == planet);
                    tas.ChangeMap(spring.UnitSync.MapList[sel.MapName]);
                }
                else
                {
                    ah.SayBattle("not enough votes, planet stays");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #21
0
		public AbstractPoll(TasClient tas, Spring spring, AutoHost ah)
		{
			this.tas = tas;
			this.spring = spring;
			this.ah = ah;

			initialUserCount = 0;
			var b = tas.GetBattle();
			if (b != null) {
				foreach (var us in b.Users) {
					if (us.name != tas.UserName) {
						users.Add(us.name);
						votes.Add(0);
						if (!us.IsSpectator) initialUserCount++;
					}
				}
			}
		}
Beispiel #22
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (allowedAlly != -1)
            {
                int ally = tas.GetBattle().Users.Where(u => u.name == e.UserName && !u.IsSpectator).Select(u => u.AllyNumber).SingleOrDefault();
                if (ally != allowedAlly)
                {
                    AutoHost.Respond(tas, spring, e, "Only smaller team can vote");
                    return(false);
                }
            }


            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    ah.SayBattle("vote successful - force starting");
                    ah.ComForceStart(e, words);
                }
                else
                {
                    ah.SayBattle("not enough votes");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #23
0
 bool IVotable.Init(TasSayEventArgs e, string[] words)
 {
     if (words.Length == 0)
     {
         AutoHost.Respond(tas, spring, e, "You must specify planet name");
         return(false);
     }
     string[] vals;
     int[]    indexes;
     if (ah.FilterPlanets(words, out vals, out indexes) > 0)
     {
         planet = vals[0];
         ah.SayBattle(string.Format("Do you want to change planet to {0}? !vote 1 = yes, !vote 2 = no", planet));
         return(true);
     }
     else
     {
         AutoHost.Respond(tas, spring, e, "Cannot find such planet");
         return(false);
     }
 }
        static void SlaveStartSpring(AutoHost ah, List <UserBattleStatus> team)
        {
            var serv = GlobalConst.GetSpringieService();

            var context = ah.tas.MyBattle.GetContext();

            context.Players = team.Select(x => new PlayerTeam()
            {
                AllyID = x.AllyNumber, Name = x.Name, LobbyID = x.LobbyUser.AccountID, TeamID = x.TeamNumber, IsSpectator = false
            }).ToList();

            var balance = serv.BalanceTeams(context, true, null, null);

            ah.ApplyBalanceResults(balance);
            context.Players = balance.Players;
            context.Bots    = balance.Bots;

            ah.SayBattle("please wait, game is about to start");
            ah.StopVote();
            ah.slaveContextOverride = context;
            ah.tas.StartGame();
        }
Beispiel #25
0
        bool IVotable.Init(TasSayEventArgs e, string[] words)
        {
            if (words.Length == 0)
            {
                AutoHost.Respond(tas, spring, e, "You must specify map name");
                return(false);
            }

            string[] vals;
            int[]    indexes;
            if (ah.FilterMaps(words, out vals, out indexes) > 0)
            {
                map = vals[0];
                ah.SayBattle("Do you want to change map to " + map + "? !vote 1 = yes, !vote 2 = no");
                return(true);
            }
            else
            {
                AutoHost.Respond(tas, spring, e, "Cannot find such map");
                return(false);
            }
        }
Beispiel #26
0
        public bool Init(TasSayEventArgs e, string[] words)
        {
            if (words.Length == 0)
            {
                AutoHost.Respond(tas, spring, e, "You must specify player name");
                return(false);
            }

            string[] players;
            int[]    indexes;
            if (AutoHost.FilterUsers(words, tas, spring, out players, out indexes) > 0)
            {
                player = players[0];
                ah.SayBattle("Do you want to kick " + player + "? !vote 1 = yes, !vote 2 = no");
                return(true);
            }
            else
            {
                AutoHost.Respond(tas, spring, e, "Cannot find such player");
                return(false);
            }
        }
Beispiel #27
0
        public bool Init(TasSayEventArgs e, string[] words)
        {
            if (words.Length == 0)
            {
                AutoHost.Respond(tas, spring, e, "You must specify preset name");
                return(false);
            }

            string[] vals;
            int[]    indexes;
            if (AutoHost.FilterPresets(words, ah, out vals, out indexes) > 0)
            {
                presetId   = indexes[0];
                presetName = vals[0];
                ah.SayBattle("Do you want to apply preset " + presetName + "? !vote 1 = yes, !vote 2 = no");
                return(true);
            }
            else
            {
                AutoHost.Respond(tas, spring, e, "cannot find such preset");
                return(false);
            }
        }
Beispiel #28
0
        public bool Vote(TasSayEventArgs e, string[] words)
        {
            int vote;

            if (!RegisterVote(e, words, out vote))
            {
                AutoHost.Respond(tas, spring, e, "You must vote valid option/not be a spectator");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    if (player == "")
                    {
                        ah.SayBattle("vote successful - boss removed");
                    }
                    else
                    {
                        ah.SayBattle("vote successful - new boss is " + player);
                    }
                    ah.BossName = player;
                }
                else
                {
                    ah.SayBattle("not enough votes");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #29
0
 public bool Init(TasSayEventArgs e, string[] words)
 {
     if (words.Length == 0)
     {
         ah.SayBattle("Do you want to rehost this game? !vote 1 = yes, !vote 2 = no");
         return(true);
     }
     else
     {
         string[] mods;
         int[]    indexes;
         if (AutoHost.FilterMods(words, tas, spring, out mods, out indexes) == 0)
         {
             AutoHost.Respond(tas, spring, e, "cannot find such mod");
             return(false);
         }
         else
         {
             modname = mods[0];
             ah.SayBattle("Do you want to rehost this game to " + modname + "? !vote 1 = yes, !vote 2 = no");
             return(true);
         }
     }
 }
Beispiel #30
0
 public VotePreset(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
 void CheckAutoCloseSlave(bool exited, AutoHost slave)
 {
     if (exited && slave.tas.MyBattle.NonSpectatorCount < ah.config.MinToJuggle && !slave.spring.IsRunning)
     {
         foreach (var p in slave.tas.MyBattle.Users.Values.Where(x => !x.IsSpectator && x.Name != slave.tas.MyBattle.Founder.Name)) slave.tas.ForceJoinBattle(p.Name, tas.MyBattleID);
         Program.main.StopAutohost(slave);
     }
 }
Beispiel #32
0
		public VoteForceStart(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) {}
 internal static int FilterPresets(string[] words, AutoHost autohost, out string[] vals, out int[] indexes)
 {
   string[] temp = new string[autohost.presets.Count];
   int cnt = 0;
   foreach (Preset p in autohost.presets) temp[cnt++] = p.Name + " --> " + p.Description;
   return Filter(temp, words, out vals, out indexes);
 }
Beispiel #34
0
		public VoteSetOptions(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) {}
        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();
        }
 internal static int FilterMods(string[] words, AutoHost ah, out string[] vals, out int[] indexes)
 {
     var result = ah.cache.FindResourceData(words, ResourceType.Mod);
     vals = result.Select(x => x.InternalName).ToArray();
     indexes = result.Select(x => x.ResourceID).ToArray();
     return vals.Length;
 }
Beispiel #37
0
 public void StopAutohost(AutoHost ah)
 {
     lock (autoHosts)
     {
         autoHosts.Remove(ah);
     }
     ah.Dispose();
 }
 public AutoHost SpawnAutoHost(AhConfig config, SpawnConfig spawnData)
 {
     AutoHost ah;
     lock (autoHosts)
     {
         ah = new AutoHost(MetaCache, config, GetFreeHostingPort(), spawnData);
         var otherClone = autoHosts.Where(x => x.config.Login == config.Login).Max(x => (int?)x.CloneNumber);
         if (otherClone.HasValue) ah.CloneNumber = otherClone.Value + 1;
         
         autoHosts.Add(ah);
     }
     return ah;
 }
Beispiel #39
0
		public VotePlanet(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
		{
			this.tas = tas;
			this.spring = spring;
			this.ah = ah;

			var pw = Program.main.PlanetWars;
			var fact = pw.GetOffensiveFaction();
			faction = fact.Name;

			users.Clear();
			votes.Clear();

			initialUserCount = 0;
			var b = tas.GetBattle();
			if (b != null) {
				foreach (var us in b.Users) {
					if (us.name != tas.UserName && !us.IsSpectator && pw.GetPlayerInfo(us.name).FactionName == faction) {
						users.Add(us.name);
						votes.Add(0);
						initialUserCount++;
					}
				}
			}
		}
Beispiel #40
0
 public VoteKickSpec(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
 public ResourceLinkSpringieClient(AutoHost ah)
 {
     this.ah = ah;
     plasmaService = GlobalConst.GetContentService();
 }
Beispiel #42
0
        //new const double ratio = 0.50;

        public VoteBoss(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
        {
        }
Beispiel #43
0
		//new const double ratio = 0.50;

		#region Constructors

		public VoteBoss(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) {}
Beispiel #44
0
 public VoteSetOptions(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
Beispiel #45
0
 public VoteForceStart(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
Beispiel #46
0
    public bool Start()
    {
      if (config.AttemptToRecconnect) {
        recon = new Timer(config.AttemptReconnectInterval*1000);
        recon.Elapsed += new ElapsedEventHandler(recon_Elapsed);
      }

      recon.Enabled = false;

      try {
        spring = new Spring(config.SpringPath);
      } catch {
        MessageBox.Show("Spring not found in " + config.SpringPath, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        OpenFileDialog od = new OpenFileDialog();
        od.FileName = Spring.ExecutableName;
        od.DefaultExt = Path.GetExtension(Spring.ExecutableName);
        od.InitialDirectory = config.SpringPath;
        od.Title = "Please select your spring installation";
        od.RestoreDirectory = true;
        od.CheckFileExists = true;
        od.CheckPathExists = true;
        od.AddExtension = true;
        od.Filter = "Executable (*.exe)|*.exe";
        DialogResult dr = od.ShowDialog();
        if (dr == DialogResult.OK) {
          config.SpringPath = Path.GetDirectoryName(od.FileName);
          SaveConfig();
          try {
            spring = new Spring(config.SpringPath);
          } catch (Exception e) {
            MessageBox.Show(e.ToString(), "Error while checking spring, exiting");
            Application.Exit();
            return false;
          }
        } else {
          MessageBox.Show("Spring not found, exiting");
          Application.Exit();
          return false;
        }
      }

      tas = new TasClient();
      tas.ConnectionLost += new EventHandler<TasEventArgs>(tas_ConnectionLost);
      tas.Connected += new EventHandler<TasEventArgs>(tas_Connected);
      tas.LoginDenied += new EventHandler<TasEventArgs>(tas_LoginDenied);
      tas.LoginAccepted += new EventHandler<TasEventArgs>(tas_LoginAccepted);
      tas.Said += new EventHandler<TasSayEventArgs>(tas_Said);
      tas.MyStatusChangedToInGame += new EventHandler<TasEventArgs>(tas_MyStatusChangedToInGame);
      spring.SpringExited += new EventHandler(spring_SpringExited);
      spring.SpringStarted += new EventHandler(spring_SpringStarted);
      spring.PlayerSaid += new EventHandler<SpringLogEventArgs>(spring_PlayerSaid);
      autoHost = new AutoHost(tas, spring, null);
      autoUpdater = new AutoUpdater(spring, tas);

      if (config.StatsEnabled) stats = new Stats(tas, spring);
      try {
        tas.Connect(config.ServerHost, config.ServerPort);
      } catch {
        recon.Start();
      }
      return true;
    }
        static void SlaveStartSpring(AutoHost ah, List<UserBattleStatus> team)
        {
            var serv = GlobalConst.GetSpringieService();

            var context = ah.tas.MyBattle.GetContext();
            context.Players = team.Select(x => new PlayerTeam() { AllyID = x.AllyNumber, Name = x.Name, LobbyID = x.LobbyUser.AccountID, TeamID = x.TeamNumber, IsSpectator = false }).ToList();

            var balance = serv.BalanceTeams(context, true, null, null);
            ah.ApplyBalanceResults(balance);
            context.Players = balance.Players;
            context.Bots = balance.Bots;

            ah.SayBattle("please wait, game is about to start");
            ah.StopVote();
            ah.slaveContextOverride = context;
            ah.tas.StartGame();
        }
Beispiel #48
0
 public AutoHost SpawnAutoHost(AhConfig config, SpawnConfig spawnData)
 {
     AutoHost ah;
     lock (autoHosts)
     {
         ah = new AutoHost(MetaCache, config, GetFreeHostingPort(), spawnData);
         autoHosts.Add(ah);
     }
     return ah;
 }
Beispiel #49
0
		public VotePreset(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) {}
Beispiel #50
0
		public VoteKickSpec(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) {}
Beispiel #51
0
        public bool Start()
        {
            if (config.AttemptToRecconnect) {
                recon = new Timer(config.AttemptReconnectInterval*1000);
                recon.Elapsed += recon_Elapsed;
            }

            recon.Enabled = false;
            spring = new Spring();


            tas = new TasClient();
            tas.ConnectionLost += tas_ConnectionLost;
            tas.Connected += tas_Connected;
            tas.LoginDenied += tas_LoginDenied;
            tas.LoginAccepted += tas_LoginAccepted;
            tas.Said += tas_Said;
            tas.MyStatusChangedToInGame += tas_MyStatusChangedToInGame;
            tas.ChannelUserAdded += tas_ChannelUserAdded;
            spring.SpringExited += spring_SpringExited;
            spring.SpringStarted += spring_SpringStarted;
            spring.PlayerSaid += spring_PlayerSaid;
            autoHost = new AutoHost(tas, spring, null);
            if (config.PlanetWarsEnabled) InitializePlanetWarsServer();
            autoUpdater = new AutoUpdater(spring, tas);

            if (config.StatsEnabledReal) stats = new Stats(tas, spring);
            try {
                tas.Connect(config.ServerHost, config.ServerPort);
            } catch {
                recon.Start();
            }
            return true;
        }