예제 #1
0
        public static List <string> GetHeroNameList(string directory)
        {
            List <string>            heroNameList = new List <string>();
            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.getIDfromLowercaseHeroname(); // key is hero_name, value is ID;

            string[] infoFile = File.ReadAllLines(directory + "info.txt");
            foreach (string line in infoFile)
            {
                if (line.Contains("hero_name"))
                {
                    int key = hero_table[ConvertedHeroName.Get(line)];

                    heroNameList.Add(ID_table[key]);
                }
            }

            return(heroNameList);
        }
예제 #2
0
        void HandleHeroGraph()
        {
            Player[] heroes = consoleData.Heroes;
            foreach (var hero in heroes)
            {
                if (hero.HeroName == "")
                {
                    return;
                }
            }

            List <double> teamHealth = new List <double> {
                0, 0, 0, 0, 0
            };
            List <double> teamMaxHealth = new List <double> {
                0, 0, 0, 0, 0
            };

            List <int> heroIDs = new List <int>();

            teamHealth.Add(gsi.Health);
            teamMaxHealth.Add(gsi.MaxHealth);

            heroIDs.Add(hero_table[ConvertedHeroName.Get(gsi.Name)]);

            int    indexStart = 0;
            string playerTeam = gsi.Team;

            switch (playerTeam) // Player always 0, Radiant next, Dire last
            {
            case "Radiant":
                indexStart = 1;
                break;

            case "Dire":
                indexStart = 6;
                break;
            }

            foreach (string name in heroID.heroName)
            {
                if (name == null)
                {
                    continue;
                }

                for (int i = indexStart; i < indexStart + 4; i++)
                {
                    if (ConvertedHeroName.Get(name).Contains(ConvertedHeroName.Get(heroes[i].HeroName)))
                    {
                        teamHealth.Add(heroes[i].Health);
                        teamMaxHealth.Add(heroes[i].MaxHealth);

                        heroIDs.Add(hero_table[ConvertedHeroName.Get(name)]);

                        break;
                    }
                }
            }

            overlay.AddHeroGraphIcons(heroIDs);
            overlay.AddHPs(teamHealth.ToArray(), teamMaxHealth.ToArray());
            overlay.AddHp(teamHealth[0]);
        }
예제 #3
0
        /*
         * take real time picks and give 5 suggested hero.
         */
        private void HandleHeroSelection()
        {
            string[] heroesSelected = consoleData.HeroesSelected;
            int      team_side      = 0;

            if (gsi.Name != "null")
            {
                string teamname = gsi.Team;

                if (teamname == "Dire")
                {
                    team_side = 3;
                }
                else if (teamname == "Radiant")
                {
                    team_side = 2;
                }
                if (team_side != 0)
                {
                    int[]  hero_sequence_enemy    = new int[5];
                    int[]  hero_sequence_teammate = new int[5];
                    int    flagEnemy = 0;
                    int    flagTeam  = 0;
                    int    heroID;
                    string curHeroName;
                    for (int i = 0; i < 10; i++)
                    {
                        if (heroesSelected[i] == "null")
                        {
                            continue;
                        }
                        else
                        {
                            curHeroName = heroesSelected[i];
                            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(curHeroName, "");
                            name   = string.Join("", name.Split(new string[] { "_" }, StringSplitOptions.None));
                            name   = ConvertedHeroName.Get(name);
                            heroID = hero_table[name];
                        }

                        if (i < 5 && team_side == 2)
                        {
                            hero_sequence_teammate[flagTeam] = heroID;
                            flagTeam++;
                        }
                        else if (i < 5 && team_side == 3)
                        {
                            hero_sequence_enemy[flagEnemy] = heroID;
                            flagEnemy++;
                        }
                        else if (i >= 5 && team_side == 2)
                        {
                            hero_sequence_enemy[flagEnemy] = heroID;
                            flagEnemy++;
                        }
                        else if (i >= 5 && team_side == 3)
                        {
                            hero_sequence_teammate[flagTeam] = heroID;
                            flagTeam++;
                        }
                    }
                    string[] heroes    = new string[5];
                    string[] heroesimg = new string[5];
                    int      diff      = 3;
                    int[]    sugHeroID = counter_pick_logic.logic_counter_1(hero_sequence_enemy, hero_sequence_teammate, new int[0], diff);


                    // Check mark update version;
                    //int counter = 0;
                    //if (CurrentTick > table_checkmark[counter, 0] && CurrentTick < table_checkmark[counter, 1])
                    //{
                    //    overlay.XorCheck(table_checkmark[counter, 2]);
                    //    index = index - 1;
                    //    counter++;
                    //}
                    //else
                    //{
                    //    overlay.XorCheck(0);
                    //}

                    for (int j = 0; j < 5; j++)
                    {
                        heroesimg[j] = sugHeroID[j].ToString();
                        heroes[j]    = ID_table[sugHeroID[j]];
                    }

                    overlay.AddHeroesSuggestionMessage(heroes, heroesimg);
                }
                else
                {
                    //Console.WriteLine(teamname);
                }
            }
            else
            {
                //Console.WriteLine("Picked"+ gsi.Name);
            }
        }
예제 #4
0
        private void HandleGamePlay()
        {
            long   item_now_ms = DateTimeOffset.Now.ToUnixTimeMilliseconds();
            string name        = "";

            if (heroInfoflag == 0)
            {
                heroInfoflag         = 1;
                timeSinceheroInfo_ms = item_now_ms;
            }
            if (item_now_ms - timeSinceheroInfo_ms <= 20000 && heroInfoflag == 1)
            {
                Dictionary <int, string> hero_Intro_Dic = hero_Intro.getHeroIntro();
                name = gsi.Name.Replace("hero_", "*");
                string[] namestr1 = name.Split('*');
                name = string.Join("", namestr1[namestr1.Length - 1].Split(new string[] { "_" }, StringSplitOptions.None));
                name = ConvertedHeroName.Get(name);
                string hero_Intro_String = hero_Intro_Dic[hero_table[name]];
                overlay.AddHeroInfoMessage(hero_Intro_String, "");
            }
            else
            {
                overlay.ClearHeroInfo();
            }



            // placeholders
            double[] hpToSend = new double[5] {
                0, 0, 0, 0, 0
            };
            double[] maxHpToSend = new double[5] {
                0, 0, 0, 0, 0
            };

            int healthPercent = gsi.HealthPercent;

            overlay.AddHPs(hpToSend, maxHpToSend);
            overlay.AddHp(hpToSend[0]);


            if (gsi.Health < (gsi.MaxHealth - 430) && gsi.Health != 0)
            {
                overlay.AddRetreatMessage("Low health warning! " + "Current Health: " + gsi.Health, "exclamation_mark");
            }
            else
            {
                overlay.ClearRetreat();
            }


            // For suggestion for tango and Healing_Salve.
            if (gsi.Health != 0 && gsi.Health < (gsi.MaxHealth - 130))
            {
                if (gsi.Health < (gsi.MaxHealth - 430) && gsi.Health != 0 && gsi.Items.Contains("item_flask"))
                {
                    long now_ms = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                    if (itemflag == 0 || itemflag == 1)
                    {
                        itemflag = 2;
                        timeSinceItemSuggestion_ms = now_ms;
                    }
                    if (now_ms - timeSinceItemSuggestion_ms <= 10000)
                    {
                        string item_name = item_Info_Table[8 + 2, 2];
                        string item_tip  = item_Info_Table[8 + 2, 117];
                        string item_content;
                        if (item_tip == " 0")
                        {
                            item_content = item_name + ":\n This is a good choice.";
                        }
                        else
                        {
                            item_content = item_name + ":\n " + item_tip;
                        }
                        if (itemflag == 2)
                        {
                            item_name = item_name.TrimStart(' ');
                            string item_img = item_name.Replace(" ", "_");
                            overlay.AddItemSuggestionMessage(item_content, item_img + "_icon");
                        }
                    }
                    else
                    {
                        overlay.ClearItemSuggestion();
                    }
                }
                else if (gsi.Items.Contains("item_tango"))
                {
                    long now_ms = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                    if (itemflag == 0 || itemflag == 2)
                    {
                        itemflag = 1;
                        timeSinceItemSuggestion_ms = now_ms;
                    }
                    if (now_ms - timeSinceItemSuggestion_ms <= 10000)
                    {
                        string item_name = item_Info_Table[9 + 2, 2];
                        string item_tip  = item_Info_Table[9 + 2, 117];
                        string item_content;
                        if (item_tip == " 0")
                        {
                            item_content = item_name + ":\nThis is a good choice.";
                        }
                        else
                        {
                            item_content = item_name + ":\n " + item_tip;
                        }
                        if (itemflag == 1)
                        {
                            item_name = item_name.TrimStart(' ');
                            string item_img = item_name.Replace(" ", "_");
                            overlay.AddItemSuggestionMessage(item_content, item_img + "_icon");
                        }
                    }
                    else
                    {
                        overlay.ClearItemSuggestion();
                    }
                }
            }
            if (gsi.Health == 0 || gsi.Health == gsi.MaxHealth)
            {
                itemflag = 0;
                overlay.ClearItemSuggestion();
            }


            // item suggestion to buy something
            int item_suggestion_flag = 0;

            name = gsi.Name.Replace("hero_", "*");
            string[] namestr = name.Split('*');
            name = string.Join("", namestr[namestr.Length - 1].Split(new string[] { "_" }, StringSplitOptions.None));
            name = ConvertedHeroName.Get(name);
            if (gsi.Health == 0)
            {
                int  item_id = i_info.item_suggestion_for_live(gsi.Items, name);
                long now_ms  = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                if (item_suggestion_flag == 0)
                {
                    item_suggestion_flag       = 1;
                    timeSinceItemSuggestion_ms = now_ms;
                }
                if (now_ms - timeSinceItemSuggestion_ms <= 10000)
                {
                    string item_name = item_Info_Table[item_id + 2, 2];
                    string item_tip  = item_Info_Table[item_id + 2, 117];
                    string item_content;
                    if (item_tip == " 0")
                    {
                        item_content = item_name + ":\n This is a good choice.";
                    }
                    else
                    {
                        item_content = item_name + ":\n " + item_tip;
                    }
                    if (item_suggestion_flag == 1)
                    {
                        item_name = item_name.TrimStart(' ');
                        string item_img = item_name.Replace(" ", "_");
                        overlay.AddItemSuggestionMessage(item_content, item_img + "_icon");
                    }
                }
                else
                {
                    overlay.ClearItemSuggestion();
                    item_suggestion_flag = 0;
                }
            }
        }