Ejemplo n.º 1
0
 public ReplayHeroID(string dataFolderLocation)
 {
     string[] lines = File.ReadAllLines(dataFolderLocation + "heroId.txt");
     foreach (string line in lines)
     {
         string[] words      = line.Split(' ');
         string[] substrings = Regex.Split(words[1], "Hero_");
         var      r          = new Regex(@"(?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])",
                                         RegexOptions.IgnorePatternWhitespace);
         string name = r.Replace(substrings[1], "");
         name = string.Join("", name.Split(new string[] { "_" }, StringSplitOptions.None));
         name = ConvertedHeroName.Get(name);
         int heroID = Int32.Parse(words[0]);
         heroNameToID[name]   = heroID;
         heroIDToName[heroID] = name;
     }
 }
Ejemplo n.º 2
0
        public ReplayHighlights(string dataFolderLocation, string myHero)
        {
            heroID hid = new heroID();
            Dictionary <int, string> ID_table   = hid.getHeroID();                  // key is ID, value is hero_name;
            Dictionary <string, int> hero_table = hid.getIDfromLowercaseHeroname(); // key is hero_name, value is ID;

            string timePath   = dataFolderLocation + "time.txt";
            string combatPath = dataFolderLocation + "combat.txt";

            List <String> timeLines = new List <String>(System.IO.File.ReadAllLines(timePath));

            Int32.TryParse(timeLines.First().Split(' ')[2], out this.firstTick);
            float.TryParse(timeLines.Last().Split(' ')[2], out this.lastTick);

            List <String>         combatLines = new List <String>(System.IO.File.ReadAllLines(combatPath));
            List <List <String> > killLines   = GetTeamfight(combatLines);

            this.tickInfo = new Dictionary <int, Tuple <String, List <Tuple <String, String, String> > > >();
            listInfo      = new Dictionary <int, List <Tuple <string, string, string> > >();

            foreach (var kills in killLines)
            {
                listInfo[(int)Double.Parse(kills[0])] = new List <Tuple <string, string, string> >();
                for (int i = 1; i < kills.Count; i++)
                {
                    string[] cont   = kills[i].Split(new char[] { ' ' });
                    string   killed = ID_table[hero_table[ConvertedHeroName.Get(cont[0])]];
                    string   killer = ID_table[hero_table[ConvertedHeroName.Get(cont[1])]];

                    string color = "we";
                    if (killed == myHero)
                    {
                        color = "R";
                    }
                    else if (killer == myHero)
                    {
                        color = "G";
                    }
                    listInfo[(int)Double.Parse(kills[0])].Add(new Tuple <string, string, string>(killer, killed, color));
                }
            }
        }
Ejemplo n.º 3
0
        public Dictionary <int, int> item_suggestion(int money, string dataFolderLocation, string myHero)
        {
            Dictionary <int, int> item_ID = new Dictionary <int, int>();
            heroID hid = new heroID();
            Dictionary <int, string> ID_table   = hid.getHeroID();                  // key is ID, value is hero_name;
            Dictionary <string, int> hero_table = hid.getIDfromLowercaseHeroname(); // key is hero_name, value is ID;
            int    firstTick;
            int    lastTick;
            string timePath   = dataFolderLocation + "time.txt";
            string combatPath = dataFolderLocation + "combat.txt";

            List <String> timeLines = new List <String>(System.IO.File.ReadAllLines(timePath));

            Int32.TryParse(timeLines.First().Split(' ')[0], out firstTick);
            Int32.TryParse(timeLines.Last().Split(' ')[0], out lastTick);
            List <String>         combatLines = new List <String>(System.IO.File.ReadAllLines(combatPath));
            List <List <String> > teamfight   = new List <List <string> >();
            Dictionary <int, List <Tuple <String, String, String> > > tickInfo = new Dictionary <int, List <Tuple <string, string, string> > >();
            int      currInd     = 0;
            TimeSpan prevTime    = new TimeSpan();
            TimeSpan thirty      = TimeSpan.FromSeconds(30);
            string   heroPattern = "hero.*hero";

            foreach (var line in combatLines)
            {
                if (line.Contains("[KILL]"))
                {
                    if (Regex.IsMatch(line, heroPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                    {
                        if (teamfight.Count < currInd + 1)
                        {
                            teamfight.Add(new List <String>());
                        }

                        List <String> contents = new List <String>(line.Split(new char[] { ' ' }));
                        if (prevTime == new TimeSpan())
                        {
                            prevTime = TimeSpan.FromSeconds(Double.Parse(contents[0]));
                        }

                        TimeSpan currTime = TimeSpan.FromSeconds(Double.Parse(contents[0]));

                        if (prevTime == currTime)
                        {
                            teamfight[currInd].Add(contents[0]);
                            teamfight[currInd].Add(contents[2] + " " + contents[3]);
                        }
                        else if (prevTime.Add(thirty) > currTime)
                        {
                            teamfight[currInd].Add(contents[2] + " " + contents[3]);
                        }
                        else
                        {
                            currInd++;
                            teamfight.Add(new List <String>());
                            prevTime = currTime;
                            teamfight[currInd].Add(contents[0]);
                            teamfight[currInd].Add(contents[2] + " " + contents[3]);
                        }
                    }
                }
            }
            int oneThird = (2 * firstTick + lastTick) / 8;
            int twoThird = (firstTick + 2 * lastTick) / 3;

            foreach (var kills in teamfight)
            {
                tickInfo[(int)Double.Parse(kills[0])] = new List <Tuple <string, string, string> >();
                for (int i = 1; i < kills.Count; i++)
                {
                    string[] cont   = kills[i].Split(new char[] { ' ' });
                    string   killed = ID_table[hero_table[ConvertedHeroName.Get(cont[0])]];
                    string   killer = ID_table[hero_table[ConvertedHeroName.Get(cont[1])]];
                    if (killed == myHero)
                    {
                        int itemInfo;
                        int killedID = hero_table[ConvertedHeroName.Get(killed)];
                        int curtick  = (int)(Double.Parse(kills[0]));
                        if (curtick <= oneThird)
                        {
                            itemInfo = item_KB[killedID, 1];
                        }
                        else if (twoThird > curtick && curtick > oneThird)
                        {
                            itemInfo = item_KB[killedID, 1];
                        }
                        else
                        {
                            itemInfo = item_KB[killedID, 2];
                        }
                        item_ID.Add((int)(Double.Parse(kills[0])), itemInfo);
                    }
                }
            }
            return(item_ID);
        }