コード例 #1
0
        /*
         *
         */
        public heroGenerateTypes()
        {
            string s = Path.Combine(Environment.CurrentDirectory, "Properties/herotype.txt");

            string[] lines        = System.IO.File.ReadAllLines(s);
            string[] second_lines = lines;
            int      index        = 0;
            heroID   h_ID         = new heroID();

            string[] heroesName = h_ID.getHeroName();
            Dictionary <int, string> ID_table   = h_ID.getHeroID(); // key is ID, value is hero_name;
            Dictionary <string, int> hero_table = h_ID.getIDHero(); // key is hero_name, value is ID;

            foreach (string line in lines)
            {
                if (line.Contains("["))
                {
                    string[] words     = line.Split('\t', '"', '\\');
                    string   role_name = words[0].Replace("[", "");
                    role_name = role_name.Replace("]", "");
                    string explain = words[1].Replace("\"", "");
                    type_explain[role_name] = explain;
                    index = type_explain.Count - 1;
                }
                else
                {
                    string   second_string = string.Empty;
                    string[] words         = line.Split('*');
                    for (int i = 0; i < words.Length; i++)
                    {
                        var r = new Regex(@"(?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])",
                                          RegexOptions.IgnorePatternWhitespace);

                        string   curName  = r.Replace(words[i], " ");
                        string[] nameList = curName.Split(' ');
                        curName = "";
                        for (int j = nameList.Length - 1; j >= 0; j--)
                        {
                            if (curName.Length > 0)
                            {
                                if (nameList[j].Length > 0)
                                {
                                    curName = nameList[j] + " " + curName;
                                }
                            }
                            else
                            {
                                curName = nameList[j];
                            }

                            if (hero_table.ContainsKey(curName))
                            {
                                hero_generate_type_table[hero_table[curName], index] = 1;
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public counterpick_info()
        {
            heroID h_ID = new heroID();
            Dictionary <int, string> ID_table   = h_ID.getHeroID(); // key is ID, value is hero_name;
            Dictionary <string, int> hero_table = h_ID.getIDHero(); // key is hero_name, value is ID;
            string s     = Path.Combine(Environment.CurrentDirectory, "Properties/c");
            string s_end = ".txt";
            int    i     = 1;
            string path  = "";

            while (i < 116)
            {
                path = s + i + s_end;
                string[] lines        = System.IO.File.ReadAllLines(path);
                string[] second_lines = lines;
                int      counter      = 0;
                foreach (string line in lines)
                {
                    if (counter == 0)
                    {
                        string[] words       = line.Split('\t');
                        int      length_this = words.Length;
                        string   name        = "";
                        int      count_in    = 0;
                        while (length_this > 1)
                        {
                            name = words[count_in];
                            count_in++;
                            length_this--;
                        }
                        string temp   = words[count_in].Replace('%', ' ');
                        double d_temp = Convert.ToDouble(temp);
                        int    index  = -1;
                        hero_table.TryGetValue(name, out index);
                        if (index != -1)
                        {
                            counter_info_table[i, index] = d_temp;
                        }
                        if (index == 0)
                        {
                            //Console.WriteLine(name);
                        }
                        counter++;
                    }
                    else
                    {
                        counter = 0;
                    }
                }
                i++;
            }

            string path1 = Path.Combine(Environment.CurrentDirectory, "Properties/countertable.txt");

            if (!File.Exists(path1))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path1))
                {
                    int row_number = 0;
                    while (row_number < 116)
                    {
                        double[] nthRow = GetRow(counter_info_table, row_number);
                        sw.WriteLine(convertString(nthRow));
                        row_number++;
                    }
                }
            }
        }
コード例 #3
0
        /*
         * build up the hero_ID_Client_Team Team
         */
        public void readTeam()
        {
            //count the hero name
            int count = 0;
            //count the hero team
            //int count1 = 0;
            string s = dataFolderLocation + "info.txt";

            string[]                 lines          = System.IO.File.ReadAllLines(s);
            heroIDClient             ID_client      = new heroIDClient();
            Dictionary <string, int> clientID_Dic   = ID_client.getIDHero();
            Dictionary <int, string> clientHero_Dic = ID_client.getHeroID();

            heroID ID_hero = new heroID();
            Dictionary <string, int> ID_Dic   = ID_hero.getIDHero();
            Dictionary <int, string> Hero_Dic = ID_hero.getHeroID();
            var caseInsensitiveDictionary     = new Dictionary <string, int>(
                StringComparer.OrdinalIgnoreCase);

            foreach (string key in clientID_Dic.Keys)
            {
                int value1 = 0;
                clientID_Dic.TryGetValue(key, out value1);
                if (value1 > 0)
                {
                    caseInsensitiveDictionary.Add(key, value1);
                }
            }
            int mode = 0;
            int ban  = 0;

            foreach (string line in lines)
            {
                if (mode == 1)
                {
                    if (ban == 1)
                    {
                        if (line.Contains("team"))
                        {
                            mode = 2;
                            string[] words       = line.Split(' ');
                            int      team_number = -1;
                            if (int.TryParse(words[words.Length - 1], out team_number))
                            {
                                if (team_number == 2)
                                {
                                    hero_ID_Client_Team[count, 2] = 0;
                                }
                                else
                                {
                                    hero_ID_Client_Team[count, 2] = 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (line.Contains("team"))
                        {
                            mode = 2;
                            string[] words       = line.Split(' ');
                            int      team_number = -1;
                            if (int.TryParse(words[words.Length - 1], out team_number))
                            {
                                if (team_number == 2)
                                {
                                    hero_ID_Client_Team[count, 2] = 2;
                                }
                                else
                                {
                                    hero_ID_Client_Team[count, 2] = 3;
                                }
                            }
                        }
                    }
                }
                else if (line.Contains("is_pick:"))
                {
                    mode = 1;
                    string[] words = line.Split(' ');
                    if (words[words.Length - 1].Contains("false"))
                    {
                        ban = 1;
                    }
                }
                else if (mode == 2)
                {
                    if (line.Contains("hero_id:"))
                    {
                        mode = 0;
                        string[] words       = line.Split(' ');
                        int      hero_number = -1;
                        if (int.TryParse(words[words.Length - 1], out hero_number))
                        {
                            hero_ID_Client_Team[count, 1] = hero_number;
                            string hero_name   = clientHero_Dic[hero_number];
                            int    hero_id_cur = ID_Dic[hero_name];
                            hero_ID_Client_Team[count, 0] = hero_id_cur;
                            count++;
                            ban = 0;
                        }
                    }
                }
            }

            s = dataFolderLocation + "selection.txt";

            lines = System.IO.File.ReadAllLines(s);
            foreach (string line in lines)
            {
                string[] words = line.Split(' ');
                int      tic   = Int32.Parse(words[0]);
                //int team = 0;
                int heroID = 0;
                heroID = Int32.Parse(words[2]);
                string hero_name = "";
                clientHero_Dic.TryGetValue(heroID, out hero_name);
                int cur_ID = 0;
                ID_Dic.TryGetValue(hero_name, out cur_ID);
                for (int i = 0; i < count; i++)
                {
                    if (hero_ID_Client_Team[i, 0] == cur_ID)
                    {
                        hero_ID_Client_Team[i, 3] = tic;
                    }
                }
            }
        }