예제 #1
0
파일: Funcs.cs 프로젝트: Falofa/Vulner
        static public string MakeWord(int min = 1, int max = 4)
        {
            string[] Ignore = new string[] { "con", "prn", "aux", "nul" };
            if (min > max || min < 0)
            {
                return("");
            }
            string c = "bcdfgjklmnpqrstvw"; //consonants
            string v = "aeiou";             // vowels

            string[] t = new string[] {
                "sp", "ck", "lf", "lk", "lp", "mp", "lt", "nd", "ng", "nk", "nt", "sh", "sk", "pt", "ch", "st", "ng", "er", "tch", "ll", "l", "t", "s"
            }; // endings
            string r = "";

            for (int i = 0; i < Funcs.Rnd(min, max); i++)
            {
                r += string.Format("{0}{1}", PickRnd(c), PickRnd(v));
            }
            if (r.Length == 2 || Rnd(0, 100) < 50)
            {
                r += PickRnd(t);
            }
            if (Ignore.Contains(r))
            {
                return(MakeWord(min, max));
            }
            return(r);
        }
예제 #2
0
파일: Funcs.cs 프로젝트: Falofa/Vulner
 static public T PickRnd <T>(T[] s)
 {
     return(s[Funcs.Rnd(0, s.Length)]);
 }
예제 #3
0
파일: Funcs.cs 프로젝트: Falofa/Vulner
 static public char PickRnd(string s)
 {
     return(s[Funcs.Rnd(0, s.Length)]);
 }
예제 #4
0
파일: Funcs.cs 프로젝트: Falofa/Vulner
        public static void RegexRename(string In, string Out, TerminalController Console, bool Copy = false, bool Randomize = false)
        {
            string Reg = Regex.Escape(In).Replace(@"\*", "(.+)");

            int u = 0;
            Dictionary <string, string> Fr = new Dictionary <string, string>();

            foreach (string s in Directory.GetFiles(Environment.CurrentDirectory))
            {
                FileInfo f = new FileInfo(s);
                Match    r = Regex.Match(f.Name, Reg);
                if (r.Success)
                {
                    if (Copy)
                    {
                        Fr[f.FullName] = f.FullName;
                    }
                    else
                    {
                        Fr[f.FullName] = Path.Combine(f.Directory.FullName, u.ToString("X8") + RandomString(40, 50) + "." + RandomString(3));
                        File.Move(f.FullName, Fr[f.FullName]);
                    }
                    u++;
                }
            }
            int kv = 0;
            IEnumerable <KeyValuePair <string, string> > Rf = Fr.OrderBy(o => Funcs.Rnd());
            IEnumerable <KeyValuePair <string, string> > Of = Fr.AsEnumerable();

            foreach (KeyValuePair <string, string> s in (Randomize ? Rf : Of))
            {
                FileInfo f   = new FileInfo(s.Key);
                Match    r   = Regex.Match(f.Name, Reg);
                string   res = "";
                string[] v   = new string[r.Groups.Count];
                int      i   = 0;

                foreach (Group b in r.Groups)
                {
                    v[i++] = b.Value;
                }
                res = Out;
                try
                {
                    for (int k = 0; k < v.Length; k++)
                    {
                        res = res.Replace("$" + k, v[k]);
                    }
                    res = res.Replace("$i", kv.ToString());
                    if (Copy)
                    {
                        File.Copy(s.Value, new FileInfo(res).FullName);
                    }
                    else
                    {
                        File.Move(s.Value, new FileInfo(res).FullName);
                    }
                    Console.ColorWrite("$a{0} $c=> $f{1}", f.Name, res);
                }
                catch (Exception ex)
                {
                    Console.ColorWrite("$c{0} $c=> $f{1} $c- Error: {2}", f.Name, res, ex.Message);
                }
                kv++;
            }
        }