Пример #1
0
        public void FindLinks(string[] words, FileType type, TasClient tas, TasSayEventArgs e)
        {
            if (words.Length == 0)
            {
                var b = tas.GetBattle();
                if (b == null)
                {
                    return;
                }
                Program.main.AutoHost.Respond(e, string.Format("Getting SpringDownloader mirrors for currently hosted {0}", type));
                if (type == FileType.Map)
                {
                    RequestLink(new LinkRequest(b.Map.Checksum, e));
                }
                else
                {
                    RequestLink(new LinkRequest(b.Mod.Checksum, e));
                }
            }
            else
            {
                List <string> items;
                if (type == FileType.Map)
                {
                    items = new List <string>(Program.main.Spring.UnitSyncWrapper.MapList.Keys);
                }
                else
                {
                    items = new List <string>(Program.main.Spring.UnitSyncWrapper.ModList.Keys);
                }

                int[]    resultIndexes;
                string[] resultVals;
                int      cnt = AutoHost.Filter(items.ToArray(), words, out resultVals, out resultIndexes);
                if (cnt == 0)
                {
                    Program.main.AutoHost.Respond(e, string.Format("No such {0} found", type));
                }
                Program.main.AutoHost.Respond(e, string.Format("Getting SpringDownloader mirrors for {0}, please wait", resultVals[0]));

                int hash = type == FileType.Map ? Program.main.Spring.UnitSyncWrapper.MapList[resultVals[0]].Checksum : Program.main.Spring.UnitSyncWrapper.ModList[resultVals[0]].Checksum;

                RequestLink(new LinkRequest(hash, e));
            }
        }
Пример #2
0
        public int FilterPlanets(string[] words, out string[] vals, out int[] indexes)
        {
            var options = server.GetAttackOptions(account);

            if (options != null)
            {
                var temp = new string[options.Count];
                int cnt  = 0;

                foreach (var planet in options)
                {
                    temp[cnt++] = string.Format("{0}|  {1}", planet.Name, Path.GetFileNameWithoutExtension(planet.MapName));
                }
                return(AutoHost.Filter(temp, words, out vals, out indexes));
            }
            else
            {
                vals    = null;
                indexes = null;
                return(0);
            }
        }