Esempio n. 1
0
    private void spring_GameOver(object sender, SpringLogEventArgs e)
    {
      Thread.Sleep(3000); // wait for stats
      SayBattle("Game over, exiting");
      spring.ExitGame();

      if (config.MapCycle.Length > 0) {
        mapCycleIndex = mapCycleIndex%config.MapCycle.Length;
        SayBattle("changing to another map in mapcycle");
        ComMap(TasSayEventArgs.Default, config.MapCycle[mapCycleIndex].Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries));
        mapCycleIndex++;
      }
    }
Esempio n. 2
0
    private void ProcessLogLine(string l)
    {
      Console.Write(l);
      string[] words;

      if (l.StartsWith("Player")) {
        words = l.Split(' ');
        if (l.Length > 2) {
          if (words[2] == "joined") { // player joined
            if (PlayerJoined != null) PlayerJoined(this, new SpringLogEventArgs(words[1], l));
          } else if (words[2] == "left") { // player left
            if (PlayerLeft != null) PlayerLeft(this, new SpringLogEventArgs(words[1], l));
          }
        }
      } else if (l[0] == '<') { // player said something
        words = l.Split(new char[] { '<', '>', ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
        if (PlayerSaid != null && words.Length > 1) PlayerSaid(this, new SpringLogEventArgs(words[0], words[1]));

      } else if (l.StartsWith("Lost connection to")) { // lost connection to player
        words = l.Split(' ');
        if (words.Length > 3) {
          if (PlayerDisconnected != null) PlayerDisconnected(this, new SpringLogEventArgs(words[3], l));
        }
      } else if (l.StartsWith("Team")) {
        words = l.Split(new char[] { '(', ')' });
        if (words.Length > 1) {
          if (PlayerLost != null) PlayerLost(this, new SpringLogEventArgs(words[1], l));
        }
      } else if (l == "Game over") {
        string luser = "";
        SpringLogEventArgs e = new SpringLogEventArgs(luser, l);
        if (GameOver != null) GameOver(this, e);
      }

    }
Esempio n. 3
0
        private void ProcessLogLine(string l)
        {
            string[] words;

            if (l.StartsWith("Player"))
            {
                words = l.Split(' ');
                if (l.Length > 2)
                {
                    if (words[2] == "joined")
                    {
                        // player joined
                        if (PlayerJoined != null)
                        {
                            PlayerJoined(this, new SpringLogEventArgs(words[1], l));
                        }
                    }
                    else if (words[2] == "left")
                    {
                        // player left
                        if (PlayerLeft != null)
                        {
                            PlayerLeft(this, new SpringLogEventArgs(words[1], l));
                        }
                    }
                }
            }
            else if (l[0] == '<')
            {
                // player said something
                words = l.Split(new char[] { '<', '>', ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                if (PlayerSaid != null && words.Length > 1)
                {
                    PlayerSaid(this, new SpringLogEventArgs(words[0], words[1]));
                }
            }
            else if (l.StartsWith("Lost connection to"))
            {
                // lost connection to player
                words = l.Split(' ');
                if (words.Length > 3)
                {
                    if (PlayerDisconnected != null)
                    {
                        PlayerDisconnected(this, new SpringLogEventArgs(words[3], l));
                    }
                }
            }
            else if (l.StartsWith("Team"))
            {
                words = l.Split(new char[] { '(', ')' });
                if (words.Length > 1)
                {
                    if (PlayerLost != null)
                    {
                        PlayerLost(this, new SpringLogEventArgs(words[1], l));
                    }
                }
            }
            else if (l == "Game over")
            {
                string             luser = "";
                SpringLogEventArgs e     = new SpringLogEventArgs(luser, l);
                if (GameOver != null)
                {
                    GameOver(this, e);
                }
            }
        }
Esempio n. 4
0
 void spring_PlayerJoined(object sender, SpringLogEventArgs e)
 {
   if (e.Username == UserName) return; // do not add autohost itself
   RegisterPlayerInCombat(e.Username);
 }
Esempio n. 5
0
 private void spring_PlayerSaid(object sender, SpringLogEventArgs e)
 {
   tas.GameSaid(e.Username, e.Line);
   if (config.RedirectGameChat && e.Username != tas.UserName && !e.Line.StartsWith("Allies:") && !e.Line.StartsWith("Spectators:")) tas.Say(TasClient.SayPlace.Battle, "", "[" + e.Username + "]" + e.Line, false);
 }
Esempio n. 6
0
 void spring_PlayerLost(object sender, SpringLogEventArgs e)
 {
   if (RegisterPlayerInCombat(e.Username)) {
     players[e.Username].LoseTime = DateTime.Now.Subtract(startTime);
     players[e.Username].AliveTillEnd = false;
   }
 }
Esempio n. 7
0
 void spring_PlayerLeft(object sender, SpringLogEventArgs e)
 {
   if (RegisterPlayerInCombat(e.Username)) {
     players[e.Username].LeaveTime = DateTime.Now.Subtract(startTime);
   }
 }
Esempio n. 8
0
        private void ProcessLogLine(string l)
        {
            Console.Write(l);
            string[] words;

            if (l.StartsWith("Player"))
            {
                words = l.Split(' ');
                if (l.Length > 2)
                {
                    if (words[2] == "joined") // player joined
                    {
                        joinedPlayers.Add(words[1]);
                        if (PlayerJoined != null)
                        {
                            PlayerJoined(this, new SpringLogEventArgs(words[1], l));
                        }
                    }
                    else if (words[2] == "left") // player left
                    {
                        joinedPlayers.Remove(words[1]);
                        if (PlayerLeft != null)
                        {
                            PlayerLeft(this, new SpringLogEventArgs(words[1], l));
                        }
                    }
                }
            }
            else if (l[0] == '<') // player said something
            {
                words = l.Split(new char[] { '<', '>', ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                if (PlayerSaid != null && words.Length > 1)
                {
                    PlayerSaid(this, new SpringLogEventArgs(words[0], words[1]));
                }
            }
            else if (l.StartsWith("Lost connection to")) // lost connection to player
            {
                words = l.Split(' ');
                if (words.Length > 3)
                {
                    joinedPlayers.Remove(words[3]);
                    if (PlayerDisconnected != null)
                    {
                        PlayerDisconnected(this, new SpringLogEventArgs(words[3], l));
                    }
                }
            }
            else if (l.StartsWith("Team"))
            {
                words = l.Split(new char[] { '(', ')' });
                if (words.Length > 1)
                {
                    lostPlayers.Add(words[1]);
                    if (PlayerLost != null)
                    {
                        PlayerLost(this, new SpringLogEventArgs(words[1], l));
                    }
                }
            }
            else if (l == "Game over")
            {
                string luser = "";
                if (lostPlayers.Count > 0)
                {
                    luser = lostPlayers[lostPlayers.Count - 1];
                }
                else
                {
                    luser = "";
                }
                SpringLogEventArgs e = new SpringLogEventArgs(luser, l);
                for (int i = 0; i < joinedPlayers.Count; ++i)
                {
                    if (!lostPlayers.Contains(joinedPlayers[i]))
                    {
                        e.Args.Add(joinedPlayers[i]);
                    }
                }
                if (GameOver != null)
                {
                    GameOver(this, e);
                }
            }
        }
Esempio n. 9
0
    void spring_GameOver(object sender, SpringLogEventArgs e)
    {
      string query = String.Format("a=battle&map={0}&mod={1}&title={2}&start={3}&duration={4}", battle.Map.Name, battle.Mod.Name, battle.Title, Utils.ToUnix(startTime), Utils.ToUnix(DateTime.Now.Subtract(startTime)));


      foreach (Player p in players.Values) {
        if (!p.Spectator && p.AliveTillEnd) {
          foreach (Player pset in players.Values) {
            if (pset.AllyNumber == p.AllyNumber && !pset.Spectator) pset.OnVictoryTeam = true;
          }
        }
      }

      foreach (Player p in players.Values) {
        query += "&player[]=" + p;
      }

      // send only if there were at least 2 players in game
      if (players.Count > 1) SendCommand(gatherScript, query, true, true);
    }
Esempio n. 10
0
 private void spring_PlayerDisconnected(object sender, SpringLogEventArgs e)
 {
   if (RegisterPlayerInCombat(e.Username)) players[e.Username].DisconnectTime = DateTime.Now.Subtract(startTime);
 }
Esempio n. 11
0
    void spring_GameOver(object sender, SpringLogEventArgs e)
    {
      System.Threading.Thread.Sleep(3000); // wait for stats
      tas.Say(TasClient.SayPlace.Battle, "", "Game over, exiting", true);
      spring.ExitGame();

      if (config.MapCycle.Length > 0) {
        mapCycleIndex = mapCycleIndex % config.MapCycle.Length;
        tas.Say(TasClient.SayPlace.Battle, "", "changing to another map in mapcycle", true);
        ComMap(new TasSayEventArgs(TasSayEventArgs.Origins.Player, TasSayEventArgs.Places.Battle, "", tas.UserName, "", false), config.MapCycle[mapCycleIndex].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
        mapCycleIndex++;
      }
    }
Esempio n. 12
0
		private void spring_PlayerLeft(object sender, SpringLogEventArgs e)
		{
			if (RegisterPlayerInCombat(e.Username)) {
			    players[e.Username].LeaveTime = (int)DateTime.Now.Subtract(startTime).TotalSeconds;
                players[e.Username].AliveTillEnd = false;
			}
		}
Esempio n. 13
0
 void spring_GameOver(object sender, SpringLogEventArgs e)
 {
   System.Threading.Thread.Sleep(3000); // wait for stats
   tas.Say(TasClient.SayPlace.Battle, "", "Game over, exiting", true);
   spring.ExitGame();
 }
Esempio n. 14
0
		private void spring_GameOver(object sender, SpringLogEventArgs e)
		{
			string query = String.Format("a=battle&map={0}&mod={1}&title={2}&start={3}&duration={4}", battle.Map.Name, battle.Mod.Name, battle.Title, Utils.ToUnix(startTime), Utils.ToUnix(DateTime.Now.Subtract(startTime)));

			foreach (var p in players.Values) if (!p.Spectator && p.AliveTillEnd) foreach (var pset in players.Values) if (pset.AllyNumber == p.AllyNumber && !pset.Spectator) pset.OnVictoryTeam = true;

			foreach (var p in players.Values) query += "&player[]=" + p;

			if (Program.main.config.PlanetWarsEnabled) {
				try {
					var pw = Program.main.PlanetWars;

					string response = pw.SendBattleResult(new AuthInfo {Login = Program.main.config.PlanetWarsServerLogin, Password = Program.main.config.PlanetWarsServerPassword}, battle.Map.Name, players.Values);

					Program.main.AutoHost.SayBattle(response);
					foreach (var p in players.Values) if (p.Name != tas.UserName) tas.Say(TasClient.SayPlace.User, p.Name, response, false);
				} catch (Exception ex) {
					Program.main.AutoHost.SayBattle(string.Format("Error sending planet battle result :(( {0}", ex.Message), true);
				}
			}

			// send only if there were at least 2 players in game
			if (players.Count > 1) SendCommand(gatherScript, query, true, true);
		}