public bool Setup(TasSayEventArgs e, string[] words)
        {
            string question;
            int    winCount;

            if (PerformInit(e, words, out question, out winCount))
            {
                WinCount = winCount;
                Question = question;
                if (WinCount <= 0)
                {
                    WinCount = tas.MyBattle != null ? (tas.MyBattle.NonSpectatorCount / 2 + 1) : 1;
                }
                if (WinCount <= 0)
                {
                    WinCount = 1;
                }
                // If vote is started by a spec while there are players present don't let the number go below 2.
                if (WinCount <= 1 && tas.MyBattle.NonSpectatorCount != 0 &&
                    tas.MyBattle.Users.All(u => u.Name != e.UserName || u.IsSpectator))
                {
                    WinCount = 2;
                }
                ah.SayBattle(string.Format("Poll: {0} [!y=0/{1}, !n=0/{1}]", Question, WinCount));
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 protected void SayBattle(bool inGame, string text, params object[] args)
 {
     AutoHost.SayBattle(handler.TasClient, handler.Spring, string.Format(text, args), inGame);
 }
Exemple #3
0
        public void ComPlanet(TasSayEventArgs e, string[] words)
        {
            if (words.Length == 0)
            {
                autoHost.Respond(e, "You must specify planet name");
                return;
            }
            string[] vals;
            int[]    indexes;
            if (FilterPlanets(words, out vals, out indexes) > 0)
            {
                var    info       = server.GetPlayerInfo(account, e.UserName);
                var    fact       = server.GetOffensiveFaction(account);
                bool   canset     = false;
                string bestPlayer = "";
                if (info != null)
                {
                    if (info.IsCommanderInChief)
                    {
                        canset = true;
                    }
                    else
                    {
                        canset = true;
                        int bestRank = info.RankOrder;
                        foreach (var u in tas.GetBattle().Users)
                        {
                            if (!u.IsSpectator && u.name != e.UserName && tas.GetBattle().Mod.Sides[u.Side].ToLower() == info.FactionName.ToLower())
                            {
                                var pi = server.GetPlayerInfo(account, u.name);
                                if (pi != null && pi.RankOrder < bestRank)
                                {
                                    // someone sle with better rank exists
                                    bestPlayer = pi.Name;
                                    bestRank   = pi.RankOrder;
                                    canset     = false;
                                }
                            }
                        }
                    }
                }

                if (canset)
                {
                    if (info.FactionName == fact.Name)
                    {
                        string pname = vals[0].Split('|')[0];
                        autoHost.SayBattle(string.Format("changing planet to {0} by {1}", pname, e.UserName));
                        var planet = server.GetAttackOptions(account).Where(m => m.Name == pname).Single();
                        tas.ChangeMap(Program.main.Spring.UnitSyncWrapper.MapList[planet.MapName]);
                    }
                    else
                    {
                        autoHost.Respond(e, string.Format("It's currently {0} turn", fact.Name));
                    }
                }
                else
                {
                    autoHost.Respond(e, string.Format("You are not first in command here, {0} must do it!", bestPlayer));
                }
            }
            else
            {
                autoHost.Respond(e, "Cannot find such planet.");
            }
        }