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);
 }
Esempio n. 2
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);
            }
        }
Esempio n. 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 - changing map to " + map);
                    tas.ChangeMap(spring.UnitSync.MapList[map]);
                }
                else
                {
                    ah.SayBattle("not enough votes, map stays");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 public AutoManager(AutoHost ah, TasClient tas, Spring spring)
 {
     this.ah        = ah;
     this.tas       = tas;
     this.spring    = spring;
     timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
     timer.Start();
 }
Esempio n. 5
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);
    }
Esempio n. 6
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);
        }
Esempio n. 7
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));
        }
Esempio n. 8
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);
     }
 }
Esempio n. 9
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);
     }
 }
Esempio n. 10
0
 public bool Init(TasSayEventArgs e, string[] words)
 {
     if (spring.IsRunning)
     {
         tas.Say(TasClient.SayPlace.Battle, "", "Do you want to exit this game? !vote 1 = yes, !vote 2 = no", true);
         spring.SayGame("vote to exit this game started in lobby");
         return(true);
     }
     else
     {
         AutoHost.Respond(tas, spring, e, "game not running");
         return(false);
     }
 }
Esempio n. 11
0
 public AbstractPoll(TasClient tas, Spring spring, AutoHost ah)
 {
   this.tas = tas;
   this.spring = spring;
   this.ah = ah;
   string[] usrs;
   int[] indexes;
   AutoHost.FilterUsers(new string[0], tas, spring, out usrs, out indexes);
   foreach (string s in usrs) {
     if (s != tas.UserName) {
       users.Add(s);
       votes.Add(0);
     }
   }
   initialUserCount = users.Count;
 }
Esempio n. 12
0
 public AbstractPoll(TasClient tas, Spring spring, AutoHost ah)
 {
     this.tas    = tas;
     this.spring = spring;
     this.ah     = ah;
     string[] usrs;
     int[]    indexes;
     AutoHost.FilterUsers(new string[0], tas, spring, out usrs, out indexes);
     foreach (string s in usrs)
     {
         if (s != tas.UserName)
         {
             users.Add(s);
             votes.Add(0);
         }
     }
     initialUserCount = users.Count;
 }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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 (AutoHost.FilterMaps(words, tas, spring, 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);
            }
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
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");
                return(false);
            }

            int winVote;

            if (CheckEnd(out winVote))
            {
                if (winVote == 1)
                {
                    if (player == "")
                    {
                        ah.SayBattle("vote successful - tempadmin removed");
                    }
                    else
                    {
                        ah.SayBattle("vote successful - new tempadmin is " + player);
                    }
                    ah.TempAdminName = player;
                }
                else
                {
                    ah.SayBattle("not enough votes");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 17
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);
         }
     }
 }
Esempio n. 18
0
 public VotePreset(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
Esempio n. 19
0
        //new const double ratio = 0.50;

        public VoteBoss(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
        {
        }
Esempio n. 20
0
 public VoteKickSpec(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }
Esempio n. 21
0
 public VoteForceStart(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
Esempio n. 22
0
 public VoteForceStart(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }
Esempio n. 23
0
 public VoteKickSpec(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
 {
 }
Esempio n. 24
0
        //new const double ratio = 0.50;

        public VoteTempAdmin(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah)
        {
        }
Esempio n. 25
0
 public VoteMap(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }
Esempio n. 26
0
    public bool Start()
    {
      if (config.AttemptToRecconnect) {
        recon = new System.Timers.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);
      spring.SpringStarted += new EventHandler(spring_SpringStarted);
      spring.SpringExited += new EventHandler(spring_SpringExited);
      spring.PlayerSaid += new EventHandler<SpringLogEventArgs>(spring_PlayerSaid);
      autoHost = new AutoHost(tas, spring, null);

      if (config.StatsEnabled) stats = new Stats(tas, spring);
      try {
        tas.Connect(config.ServerHost, config.ServerPort);
      } catch {
        recon.Start();
      }
      return true;
    }
Esempio n. 27
0
    //new const double ratio = 0.50;

    public VoteTempAdmin(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }