public int item_suggestion_for_live(List <string> items, 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 hero_cur_id = hero_table[myHero]; List <int> itemsID = new List <int>(); string item_name = ""; string item_lower = ""; foreach (string s in items) { item_name = s.Replace("item", ""); item_name = item_name.Replace("_", ""); if (item_name.Contains("travel")) { item_name = "bootsoftravel"; } else if (item_name.Contains("cyclone")) { item_name = "eul"; } for (int i = 3; i < 156; i++) { item_lower = item_table_info[i, 2].ToLower(); item_lower = item_lower.Replace(" ", ""); if (item_lower.Contains(item_name)) { itemsID.Add(i - 2); } } } for (int i = 0; i < 3; i++) { if (!itemsID.Contains(item_KB[hero_cur_id, i])) { return(item_KB[hero_cur_id, i]); } } return(121); }
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)); } } }
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); }