Exemple #1
0
        internal unit SellHero(HabProperties hps)
        {
            if (hps == null)
            {
                return(null);
            }

            string ID   = hps.GetStringValue("Name");
            unit   hero = Heroes.GetByUnit("ID", ID) as unit;

            if (hero != null && hero.IsDisposed)
            {
                if (Current.unit != null && Current.unit != hero &&
                    Current.unit.codeID == hero.codeID &&
                    !Current.unit.IsDisposed)
                {
                    Heroes.Remove(hero);
                    Heroes.Add(Current.unit);
                    hero = Current.unit;
                }
                else
                {
                    Heroes.Remove(hero);
                    hero = null;
                }
            }

            if (hero == null)
            {
                unit sellingTavern = null;

                // find the tavern that sold this hero

                string tavernID = DHLOOKUP.dcHeroesTaverns[hps.name];
                foreach (unit tavern in DHLOOKUP.taverns)
                {
                    if (tavern.ID == tavernID)
                    {
                        sellingTavern = tavern;
                    }
                }

                // create new hero

                hero          = new unit(hps.name);
                hero.DoSummon = true;
                hero.set_owningPlayer(Current.player, sellingTavern.x, sellingTavern.y);
                Heroes.Add(hero);

                // only new heroes process onsell event

                sellingTavern.OnSell(hero);

                // pay the gold for this hero

                Current.player.Gold = Current.player.Gold - hero.goldCost;
            }

            return(hero);
        }
Exemple #2
0
        internal void InitListByShop(unit shop)
        {
            HabPropertiesCollection hpcListItems = new HabPropertiesCollection();

            if (shop == null)
            {
                InitList(DHLOOKUP.shops);
            }
            else
            {
                DBSTRINGCOLLECTION      itemList;
                HabPropertiesCollection hpcItemProfiles;

                if (DHHELPER.IsNewVersionItemShop(shop))
                {
                    itemList        = shop.sellunits;
                    hpcItemProfiles = DHLOOKUP.hpcUnitProfiles;
                }
                else
                {
                    itemList        = shop.sellitems;
                    hpcItemProfiles = DHLOOKUP.hpcItemProfiles;
                }

                foreach (string itemID in itemList)
                {
                    HabProperties hps = hpcItemProfiles[itemID];
                    hpcListItems.Add(hps);
                }

                InitList(hpcListItems);
            }
        }
Exemple #3
0
        internal item SellItemNormal(unit shop, HabProperties hpsItem)
        {
            string  ID   = hpsItem.name;
            IRecord item = Items.GetByUnit("codeID", ID);

            bool isNewVersionItem = DHHELPER.IsNewVersionItem(ID);

            if (!(item is item) && !(item is unit))
            {
                item = isNewVersionItem ? (IRecord) new unit(hpsItem.name) : (IRecord) new item(hpsItem.name);
                Items.Add(item);
            }

            item = item.Clone();

            if (isNewVersionItem)
            {
                (item as unit).DoSummon = true;
                (item as unit).set_owningPlayer(Current.unit.get_owningPlayer()); //!

                shop.OnSell(item as unit);                                        // sell item as unit
            }
            else
            {
                shop.OnSellItem(item as item, Current.unit);
            }

            // pay the gold for this item

            int goldCost = isNewVersionItem ? (item as unit).goldCost : (item as item).goldCost;

            Current.player.Gold = Current.player.Gold - goldCost;

            return(item as item);
        }
Exemple #4
0
        // used when hero has multiple abilities with the same name,
        // which are added by triggers (example: Shadowraze)
        internal string GetAbilityVariations(HabProperties hpsOriginalAbility)
        {
            string name = hpsOriginalAbility.GetStringValue("Name");
            string art  = hpsOriginalAbility.GetStringValue("Art");
            string hotkey;

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
            {
                if ((hpsAbility.GetStringValue("Name") == name) &&
                    (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name)) &&
                    (hpsOriginalAbility.name != hpsAbility.name) &&
                    dcAbilitiesHotkeys.TryGetValue(hpsAbility.name, out hotkey))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }
            }

            return(output);
        }
Exemple #5
0
        public void showComplexItemToolTip(HabProperties hpsItem, int goldCost)
        {
            UIRichTextEx.Default.ClearText();

            if (hpsItem == null)
            {
                return;
            }

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("Tip")), UIFonts.boldArial8, Color.White);//item.ID, UIFonts.boldArial8, Color.White);

            string gold = (goldCost == 0) ? "" : goldCost + "";

            HabProperties hpsItemData = DHMpqDatabase.ItemSlkDatabase["ItemData"][hpsItem.name];

            ShowCopmlexItemPrice(gold);

            tipRTB.Rtf = UIRichTextEx.Default.CloseRtf();

            UIRichTextEx.Default.ClearText();

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("UberTip")), UIFonts.boldArial8, Color.White);//item.description.Text, UIFonts.boldArial8, Color.White);

            ubertipRTB.Rtf = UIRichTextEx.Default.CloseRtf();
        }
Exemple #6
0
        AbilityAffinityType CheckAbilityAffinity(HabProperties hpsAbility, string name, string hotkey, string buttonPos)
        {
            object abilityName;

            if (hpsAbility.TryGetValue("Name", out abilityName) && string.Equals(abilityName as string, name, StringComparison.OrdinalIgnoreCase))
            {
                // used when one ability can be replaced with another same looking ability
                // which leads to invalid hotkeys for that ability (example: Carrion Swarm)
                if ((hpsAbility.GetStringValue("Hotkey") == hotkey) &&
                    (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
                {
                    return(AbilityAffinityType.Clone);
                }
                else
                {
                    // used when hero has multiple abilities with the same name,
                    // which are added by triggers (example: Shadowraze)
                    // NOTE: must be later checked for user-defined hotkey existance to make sure
                    return(AbilityAffinityType.Variation);
                }
            }
            else
            {
                return(AbilityAffinityType.None);
            }
        }
Exemple #7
0
        internal item SellItem(unit shop, HabProperties hpsItem)
        {
            if (hpsItem == null || Current.unit == null)
            {
                return(null);
            }

            // the map script checks if buying unit
            // is located near the shop, so here we set
            // the hero's location to the selected shop's location
            // & remove other units from shop checking
            foreach (unit unit in Current.player.units.Values)
            {
                if (unit == Current.unit)
                {
                    unit.set_location(shop.get_location());
                }
                else
                {
                    unit.set_location(new location(0, 0));
                }
            }

            switch (combineMode)
            {
            case CombineMode.Fast:
                return(SellItemFast(shop, hpsItem));

            default:
                return(SellItemNormal(shop, hpsItem));
            }
        }
Exemple #8
0
        internal string GetAbilityClones(HabProperties hpsOriginalAbility, string hotkey)
        {
            string name      = hpsOriginalAbility.GetStringValue("Name");
            string art       = hpsOriginalAbility.GetStringValue("Art");
            string orgHotkey = hpsOriginalAbility.GetStringValue("Hotkey");
            string buttonPos = hpsOriginalAbility.GetStringValue("Buttonpos");

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
            {
                if ((hpsAbility.GetStringValue("Name") == name) &&
                    (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name)) &&
                    (hpsAbility.GetStringValue("Hotkey") == orgHotkey) &&
                    (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }
            }

            return(output);
        }
Exemple #9
0
        internal List <HabProperties> FindSameLookingComplexItem(HabProperties hpsItem)
        {
            if (sameLookingComplexItems == null)
            {
                sameLookingComplexItems = new Dictionary <string, List <HabProperties> >(ComplexItems.Count);
            }

            string itemArt = hpsItem.GetStringValue("art");

            List <HabProperties> hpsList;

            if (sameLookingComplexItems.TryGetValue(itemArt, out hpsList))
            {
                return(hpsList);
            }
            else
            {
                hpsList = new List <HabProperties>();
            }

            foreach (string codeID in ComplexItems.Keys)
            {
                HabProperties hpsCItem = DHLOOKUP.hpcItemProfiles[codeID];
                if (hpsCItem != null && hpsCItem.GetStringValue("art") == itemArt &&
                    IsItemNameSimilar(hpsItem, hpsCItem))
                {
                    hpsList.Add(hpsCItem);
                }
            }

            sameLookingComplexItems.Add(itemArt, hpsList);

            return(hpsList);
        }
Exemple #10
0
        private void toolTipTimer_Tick(object sender, EventArgs e)
        {
            toolTipTimer.Stop();
            toolTip = new ItemToolTipForm(this);

            HabProperties hpsItem = toolTipItem as HabProperties;

            switch (combineMode)
            {
            case CombineMode.Fast:
                List <HabProperties> hpsList = FindSameLookingComplexItem(hpsItem);
                if (hpsList.Count == 0)
                {
                    toolTip.showItemToolTip(hpsItem, false);
                }
                else
                {
                    toolTip.showComplexItemToolTip(hpsItem, GetGoldCost(hpsList[0]));
                }
                break;

            default:
                toolTip.showItemToolTip(hpsItem, false);
                break;
            }
        }
Exemple #11
0
        internal void InitList(List <unit> shops)
        {
            this.Width = this.width + 4;

            itemsLV.BeginUpdate();

            // init list

            itemsLV.Items.Clear();
            itemsLV.Groups.Clear();

            foreach (unit s in shops)
            {
                ListViewGroup Group = new ListViewGroup(s.codeID, s.ID);
                Group.Tag = s;

                itemsLV.Groups.Add(Group);

                DBSTRINGCOLLECTION      itemList;
                HabPropertiesCollection hpcItemProfiles;

                if (DHHELPER.IsNewVersionItemShop(s))
                {
                    itemList        = s.sellunits;
                    hpcItemProfiles = DHLOOKUP.hpcUnitProfiles;
                }
                else
                {
                    itemList        = s.sellitems;
                    hpcItemProfiles = DHLOOKUP.hpcItemProfiles;
                }


                foreach (string itemID in itemList)
                {
                    HabProperties hpsItem = hpcItemProfiles[itemID];

                    string iconName = hpsItem.GetStringValue("Art");
                    if (String.IsNullOrEmpty(iconName))
                    {
                        continue;
                    }

                    ListViewItem lvi_Item = new ListViewItem();

                    lvi_Item.ImageKey = iconName;
                    lvi_Item.Tag      = hpsItem;
                    lvi_Item.Group    = Group;

                    itemsLV.Items.Add(lvi_Item);
                }
            }

            itemsLV.EndUpdate();

            DisplayCaption();
        }
Exemple #12
0
        internal void PickNewHero(string heroID)
        {
            HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[heroID];

            Heroes.RemoveByUnit("ID", hpsHero.GetStringValue("Name"));

            unit hero = SellHero(hpsHero);

            mainOwner.cbForm.manual_summon(hero);
        }
Exemple #13
0
        internal Dictionary <string, List <KeyValuePair <string, AbilityAffinityType> > > CollectAffinedAbilities()
        {
            SplashScreen splashScreen = new SplashScreen();

            splashScreen.Show();
            splashScreen.ShowText("Collecting affined abilities...");

            int progressCounter = 0;
            Dictionary <string, List <KeyValuePair <string, AbilityAffinityType> > > result = new Dictionary <string, List <KeyValuePair <string, AbilityAffinityType> > >((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase);

            foreach (string heroID in DHLOOKUP.dcHeroesTaverns.Keys)
            {
                HabProperties hpsHeroAbilities = DHLOOKUP.hpcUnitAbilities[heroID];

                List <string> abilList = hpsHeroAbilities.GetStringListValue("heroAbilList");
                foreach (string abilID in abilList)
                {
                    if (!result.ContainsKey(abilID))
                    {
                        HabProperties hpsAbilityProfile = DHLOOKUP.hpcAbilityProfiles[abilID];

                        string name   = hpsAbilityProfile.GetStringValue("Name");
                        string hotkey = hpsAbilityProfile.GetStringValue("Hotkey");
                        if (hotkey == "")
                        {
                            hotkey = hpsAbilityProfile.GetStringValue("Researchhotkey").Trim('"');
                        }
                        string buttonPos = hpsAbilityProfile.GetStringValue("Buttonpos");

                        List <KeyValuePair <string, AbilityAffinityType> > affinedAbilities = new List <KeyValuePair <string, AbilityAffinityType> >();
                        foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                        {
                            if (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                            {
                                AbilityAffinityType affinityType = CheckAbilityAffinity(hpsAbility, name, hotkey, buttonPos);

                                if (affinityType != AbilityAffinityType.None)
                                {
                                    affinedAbilities.Add(new KeyValuePair <string, AbilityAffinityType>(hpsAbility.name, affinityType));
                                }
                            }
                        }

                        // save affined abilities for current ability
                        result.Add(abilID, affinedAbilities);
                    }
                }

                splashScreen.ShowProgress((double)progressCounter++, (double)DHLOOKUP.dcHeroesTaverns.Keys.Count);
            }

            splashScreen.Close();

            return(result);
        }
Exemple #14
0
        internal void InitListByState(ListSwitch ls)
        {
            if (DHMpqDatabase.UnitSlkDatabase.Count == 0)
            {
                return;
            }

            HabPropertiesCollection hpcShortHeroes = new HabPropertiesCollection();

            switch (ls)
            {
            case ListSwitch.All:
                foreach (unit tavern in DHLOOKUP.taverns)
                {
                    foreach (string unitID in tavern.sellunits)
                    {
                        HabProperties hps = DHLOOKUP.hpcUnitProfiles[unitID];
                        hpcShortHeroes.Add(hps);
                    }
                }
                break;

            case ListSwitch.Sentinel:
                foreach (unit tavern in DHLOOKUP.taverns)
                {
                    if (tavern.y < 0)
                    {
                        foreach (string unitID in tavern.sellunits)
                        {
                            HabProperties hps = DHLOOKUP.hpcUnitProfiles[unitID];
                            hpcShortHeroes.Add(hps);
                        }
                    }
                }
                break;

            case ListSwitch.Scourge:
                foreach (unit tavern in DHLOOKUP.taverns)
                {
                    if (tavern.y > 0)
                    {
                        foreach (string unitID in tavern.sellunits)
                        {
                            HabProperties hps = DHLOOKUP.hpcUnitProfiles[unitID];
                            hpcShortHeroes.Add(hps);
                        }
                    }
                }
                break;
            }

            InitList(hpcShortHeroes);
        }
Exemple #15
0
        private void load_hero_build(HabProperties hpsHero)
        {
            // set level
            Current.unit.Level = hpsHero.GetIntValue("Level");

            // set stats
            Current.unit.set_naked_attr(PrimAttrType.Str, hpsHero.GetIntValue("Str"));
            Current.unit.set_naked_attr(PrimAttrType.Agi, hpsHero.GetIntValue("Agi"));
            Current.unit.set_naked_attr(PrimAttrType.Int, hpsHero.GetIntValue("Int"));

            // get aquisition order
            HabPropertiesCollection hpcAcquisition = hpsHero.GetHpcValue("acquisition");

            // items
            List <string> items = hpsHero.GetStringListValue("items");

            // abilities
            List <string> abilities = hpsHero.GetStringListValue("abilities");

            // process acquisition order

            // make sure triggers will not screw things up
            Current.unit.Inventory.DisableMessages();

            for (int i = 0; i < hpcAcquisition.Count; i++)
            {
                HabProperties hpsAcquired = hpcAcquisition[i + ""];

                string codeID = hpsAcquired.GetStringValue("codeID");

                if (items.Contains(codeID))
                {
                    Current.unit.Inventory.put_item(new item(codeID), hpsAcquired.GetIntValue("slot"));
                }
                else
                if (abilities.Contains(codeID))
                {
                    DBABILITY ability = Current.unit.heroAbilities.GetByAlias(codeID);

                    int level = hpsAcquired.GetIntValue("level");
                    for (int j = 1; j <= level; j++)
                    {
                        ability.Level = j;
                    }
                }
            }

            // restore original state
            Current.unit.Inventory.EnableMessages();

            UpdateHeroLeveling();
        }
Exemple #16
0
            public static DBUPGRADE getUpgrade(string upgradeID)
            {
                HabProperties hps = DHLOOKUP.hpcUpgradeData[upgradeID];

                if (hps == null)
                {
                    return(null);
                }
                else
                {
                    return(new DBUPGRADE(hps));
                }
            }
Exemple #17
0
        public DialogResult ShowDialog(HabPropertiesCollection hpcCfg)
        {
            this.hpcHeroTagsContainer = hpcCfg;

            if (!hpcHeroTagsContainer.TryGetValue("HeroTags", out hpsHeroTags))
            {
                hpsHeroTags = new HabProperties(heroes.Count);
                hpcHeroTagsContainer.AddUnchecked("HeroTags", hpsHeroTags);
            }

            heroTagGridView.RowCount = heroes.Count;

            return(base.ShowDialog());
        }
Exemple #18
0
            internal UPGRADEPROFILE(DBUPGRADE u)
            {
                owner = u;

                hpsInitialData = DHMpqDatabase.UpgradeSlkDatabase["Profile"][u.codeID];

                ////////////////////////
                //  get codeID
                ////////////////////////

                this.m_codeID = hpsInitialData.name;

                ////////////////////////
                //  get name
                ////////////////////////

                this.name = hpsInitialData.GetStringListValue("Name");

                ////////////////////////
                //  get tip
                ////////////////////////

                tip = hpsInitialData.GetStringListValue("Tip");

                ////////////////////////
                //  get ubertip
                ////////////////////////

                ubertip = hpsInitialData.GetStringListValue("Ubertip");

                ////////////////////////
                //  get hotkey
                ////////////////////////

                this.hotkey = hpsInitialData.GetStringValue("Hotkey");

                ////////////////////////
                //  get slot priority
                ////////////////////////

                List <string> buttonpos = hpsInitialData.GetStringListValue("Buttonpos");

                slotPriority = RecordSlotComparer.get_slot(Convert.ToInt32(buttonpos[0]), Convert.ToInt32(buttonpos[1]));

                ////////////////////////
                //  get art
                ////////////////////////

                this.art = hpsInitialData.GetStringListValue("Art");
            }
Exemple #19
0
        internal item SellItemFast(unit shop, HabProperties hpsItem)
        {
            List <HabProperties> hpsList = FindSameLookingComplexItem(hpsItem);

            if (hpsList.Count == 0)
            {
                return(SellItemNormal(shop, hpsItem));
            }
            else
            {
                int goldCost = GetGoldCost(hpsList[0]);
                return(SellItemNormal(shop, hpsList[0], goldCost));
            }
        }
Exemple #20
0
        internal void LoadHeroBuild(string filename)
        {
            HabPropertiesCollection hpcBuild = new HabPropertiesCollection();

            hpcBuild.ReadFromFile(filename);

            try
            {
                HabProperties hpsHero = hpcBuild.GetByOrder(0);

                // load specified map if current map is empty
                if (Current.map == null)
                {
                    string mapfile = hpsHero.GetStringValue("Map");
                    if (File.Exists(mapfile))
                    {
                        LoadMap(mapfile);
                    }
                    else
                    {
                        MessageBox.Show(
                            "The map file '" + mapfile + "' specified in this hero build cannot be found." +
                            "\nYou can open this map manually (DotA map->Open...) and then try to load this hero build again");
                        return;
                    }
                }

                // pick specified hero
                hlForm.PickNewHero(hpsHero.name);

                if (!Current.unit.IsDisposed)
                {
                    load_hero_build(hpsHero);
                }
                else
                {
                    // delay this build until the hero
                    // will be found by hero provider
                    hpsProvidedHeroBuild = hpsHero;
                }

                UpdateRecentBuild(filename);
            }
            catch
            {
                MessageBox.Show("Invalid Hero Build file");
                return;
            }
        }
Exemple #21
0
        private void killCreepB_Click(object sender, EventArgs e)
        {
            HabProperties hpsProfile = creepsCmbB.SelectedItem as HabProperties;

            player p = player.players[12];

            for (int i = 0; i < (int)creepsNumUD.Value; i++)
            {
                unit u = p.add_unit(hpsProfile.name);

                u.OnDeath(Current.unit);

                u.destroy();
            }
        }
Exemple #22
0
        internal void UpdateRecentMap(string filename)
        {
            HabProperties hps = DHCFG.Items["RecentMaps"];

            if (filename != null && !hps.ContainsValue(Path.GetFullPath(filename)))
            {
                int length = (hps.Count >= 5) ? hps.Count : (hps.Count + 1);

                for (int i = length; i > 1; i--)
                {
                    hps[i + ""] = hps[(i - 1) + ""];
                }

                hps["1"] = Path.GetFullPath(filename);
            }

            fileToolStripMenuItem.DropDownItems.Clear();

            fileToolStripMenuItem.DropDownItems.Add(openFileToolStripMenuItem);

            if (hps.Count > 0)
            {
                fileToolStripMenuItem.DropDownItems.Add(recentToolStripSeparator);
            }

            object value;
            string key;

            for (int i = 1; i <= hps.Count; i++)
            {
                if (hps.TryGetValue(key = i + "", out value))
                {
                    ToolStripMenuItem tsmi = new ToolStripMenuItem();
                    tsmi.Name   = key;
                    tsmi.Text   = Path.GetFileName(value as string);
                    tsmi.Tag    = value;
                    tsmi.Click += new EventHandler(loadRecentMap_Click);

                    fileToolStripMenuItem.DropDownItems.Add(tsmi);
                }
            }

            fileToolStripMenuItem.DropDownItems.Add(propertiesToolStripSeparator);
            fileToolStripMenuItem.DropDownItems.Add(propertiesToolStripMenuItem);
            fileToolStripMenuItem.DropDownItems.Add(exitToolStripSeparator);
            fileToolStripMenuItem.DropDownItems.Add(exitToolStripMenuItem);
        }
Exemple #23
0
        private void heroesGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex >= heroes.Count)
            {
                return;
            }

            unit hero = heroes[e.RowIndex];

            if (hero.codeID == "AnyHero")
            {
                switch (e.ColumnIndex)
                {
                case 0:     // image
                    e.Value = null;
                    break;

                case 1:     // hero name
                    e.Value = "Any Hero (Nickname-only search)";
                    break;

                case 2:     // player
                    e.Value = hero.name;
                    break;
                }
            }
            else
            {
                HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[hero.codeID];
                switch (e.ColumnIndex)
                {
                case 0:     // image
                    e.Value = DHRC.GetImage(hpsHero.GetStringValue("Art"));
                    break;

                case 1:     // hero name
                    e.Value = hero.ID;
                    break;

                case 2:     // player
                    string nick;
                    heroNicksCache.TryGetValue(hero.codeID, out nick);
                    e.Value = nick + "";
                    break;
                }
            }
        }
Exemple #24
0
        private void itemsLV_ItemActivate(object sender, EventArgs e)
        {
            foreach (int index in itemsLV.SelectedIndices)
            {
                ListViewItem  lvItem  = itemsLV.Items[index];
                HabProperties hpsItem = lvItem.Tag as HabProperties;

                unit shop = (switchButton as ToolStripButton).Tag as unit;
                if (shop == null)
                {
                    shop = lvItem.Group.Tag as unit;
                }

                OnItemActivate(SellItem(shop, hpsItem));
                break;
            }
        }
Exemple #25
0
        public void showItemToolTip(HabProperties hpsItem, bool inventory)
        {
            UIRichTextEx.Default.ClearText();

            if (hpsItem == null)
            {
                return;
            }

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("Tip")), UIFonts.boldArial8, Color.White);//item.ID, UIFonts.boldArial8, Color.White);

            string gold = null;
            string mana = null;

            HabProperties hpsItemData;

            if (DHHELPER.IsNewVersionItem(hpsItem.name))
            {
                hpsItemData = DHMpqDatabase.UnitSlkDatabase["UnitBalance"][hpsItem.name];
            }
            else
            {
                hpsItemData = DHMpqDatabase.ItemSlkDatabase["ItemData"][hpsItem.name];
            }

            bool  pawnable = DHFormatter.ToBool(hpsItemData.GetValue("pawnable"));
            DBINT goldcost = new DBINT(hpsItemData.GetValue("goldcost"));

            //int goldcost = DHFormatter.ToInt(hpsItemData.GetValue("goldcost"));

            if ((inventory && !pawnable) == false)
            {
                gold = inventory ? (goldcost / 2) + "" : goldcost.Text;
            }

            ShowPrices(mana, gold);

            tipRTB.Rtf = UIRichTextEx.Default.CloseRtf();

            UIRichTextEx.Default.ClearText();

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("UberTip")), UIFonts.boldArial8, Color.White);//item.description.Text, UIFonts.boldArial8, Color.White);

            ubertipRTB.Rtf = UIRichTextEx.Default.CloseRtf();
        }
Exemple #26
0
        static itemtype()
        {
            HabProperties hpsData = DHMpqDatabase.EditorDatabase["Data"]["itemClass"];

            int    value;
            string name;

            // 00=Permanent,WESTRING_ITEMCLASS_PERMANENT
            // NumValues=7

            foreach (KeyValuePair <string, object> kvp in hpsData)
            {
                if (int.TryParse(kvp.Key, out value))
                {
                    name = (kvp.Value as string).Split(',')[0];
                    NameValuePairs.Add(name, value);
                }
            }
        }
Exemple #27
0
        internal bool IsItemNameSimilar(HabProperties hpsItemA, HabProperties hpsItemB)
        {
            string[] name_partsA = hpsItemA.GetStringValue("Name").Split(' ');
            string[] name_partsB = hpsItemB.GetStringValue("Name").Split(' ');

            int matches = 0;

            for (int i = 0; i < name_partsA.Length; i++)
            {
                for (int j = 0; j < name_partsB.Length; j++)
                {
                    if (name_partsA[i] == name_partsB[j])
                    {
                        matches++;
                    }
                }
            }

            return(matches > 0);
        }
Exemple #28
0
        public void showHeroToolTip(HabProperties hpsHero)
        {
            this.Visible = false;
            UIRichTextEx.Default.ClearText();

            if (hpsHero == null)
            {
                return;
            }

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsHero.GetValue("Tip")), UIFonts.boldArial8, Color.White);

            tipRTB.Rtf = UIRichTextEx.Default.CloseRtf();

            ShowPrices(null, hpsHero.GetValue("goldcost") + "");

            UIRichTextEx.Default.ClearText();
            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsHero.GetStringListValue("Ubertip")), UIFonts.boldArial8, Color.White);
            ubertipRTB.Rtf = UIRichTextEx.Default.CloseRtf();
        }
Exemple #29
0
            public static DBUPGRADE[] getUpgrades(IList <string> upgradeList)
            {
                DBSTRINGCOLLECTION dbc = new DBSTRINGCOLLECTION(upgradeList);

                ArrayList al = new ArrayList();

                foreach (string upgradeID in dbc)
                {
                    HabProperties hps = DHLOOKUP.hpcUpgradeData[upgradeID];

                    if (hps == null)
                    {
                        continue;
                    }

                    DBUPGRADE upgrade = new DBUPGRADE(hps);
                    al.Add(upgrade);
                }

                return((DBUPGRADE[])al.ToArray(typeof(DBUPGRADE)));
            }
Exemple #30
0
        internal item SellItemNormal(unit shop, HabProperties hpsItem, int goldCost)
        {
            string ID   = hpsItem.name;
            item   item = Items.GetByUnit("codeID", ID) as item;

            if (item == null)
            {
                item = new item(hpsItem.name);
                Items.Add(item);
            }

            item = item.Clone() as item;

            shop.OnSellItem(item, Current.unit);

            // pay the gold for this item

            Current.player.Gold = Current.player.Gold - goldCost;

            return(item);
        }
Exemple #31
0
        internal void SaveHeroBuild(string filename)
        {
            try
            {
                HabPropertiesCollection hpcBuild = new HabPropertiesCollection();
                HabProperties hpsHero = new HabProperties();

                hpcBuild.Add(Current.unit.codeID, hpsHero);

                hpsHero["Map"] = Current.map.Name;
                hpsHero["Level"] = Current.unit.Level;

                hpsHero["Str"] = Current.unit.get_naked_attr(PrimAttrType.Str);
                hpsHero["Agi"] = Current.unit.get_naked_attr(PrimAttrType.Agi);
                hpsHero["Int"] = Current.unit.get_naked_attr(PrimAttrType.Int);

                ArrayList allAbilities = new ArrayList();

                foreach (DBABILITY ability in Current.unit.heroAbilities)
                    if (ability.LearnPoint != null)
                        allAbilities.Add(ability);

                foreach (DBITEMSLOT itemSlot in Current.unit.Inventory)
                    if (!itemSlot.IsNull)
                        allAbilities.Add(itemSlot.Item);

                allAbilities.Sort(new AbilityOrItemLearnPointComparer());

                HabPropertiesCollection acquisition = new HabPropertiesCollection(allAbilities.Count);
                for(int i=0; i<allAbilities.Count; i++)
                {
                    object obj = allAbilities[i];

                    HabProperties hpsAbilOrItem = new HabProperties();
                    hpsAbilOrItem.name = i + "";

                    if (obj is item)
                    {
                        hpsAbilOrItem["codeID"] = (obj as item).codeID;
                        hpsAbilOrItem["slot"] = Current.unit.Inventory.IndexOf(obj as item);
                    }
                    else
                        if (obj is DBABILITY)
                        {
                            hpsAbilOrItem["codeID"] = (obj as DBABILITY).Alias;
                            hpsAbilOrItem["level"] = (obj as DBABILITY).Level;
                        }

                    acquisition.Add(hpsAbilOrItem);
                }

                hpsHero["acquisition"] = acquisition;
                hpsHero["items"] = Current.unit.Inventory.ToString();
                hpsHero["abilities"] = Current.unit.heroAbilities.ToString(true);

                hpcBuild.SaveToFile(filename);

            }
            catch
            {
                MessageBox.Show("Failed to save Hero Build file");
                return;
            }
        }
Exemple #32
0
        private void load_hero_build(HabProperties hpsHero)
        {
            // set level
            Current.unit.Level = hpsHero.GetIntValue("Level");

            // set stats
            Current.unit.set_naked_attr(PrimAttrType.Str, hpsHero.GetIntValue("Str"));
            Current.unit.set_naked_attr(PrimAttrType.Agi, hpsHero.GetIntValue("Agi"));
            Current.unit.set_naked_attr(PrimAttrType.Int, hpsHero.GetIntValue("Int"));

            // get aquisition order
            HabPropertiesCollection hpcAcquisition = hpsHero.GetHpcValue("acquisition");

            // items
            List<string> items = hpsHero.GetStringListValue("items");

            // abilities
            List<string> abilities = hpsHero.GetStringListValue("abilities");

            // process acquisition order

            // make sure triggers will not screw things up
            Current.unit.Inventory.DisableMessages();

            for (int i = 0; i < hpcAcquisition.Count; i++)
            {
                HabProperties hpsAcquired = hpcAcquisition[i + ""];

                string codeID = hpsAcquired.GetStringValue("codeID");

                if (items.Contains(codeID))
                    Current.unit.Inventory.put_item(new item(codeID), hpsAcquired.GetIntValue("slot"));
                else
                    if (abilities.Contains(codeID))
                    {
                        DBABILITY ability = Current.unit.heroAbilities.GetByAlias(codeID);

                        int level = hpsAcquired.GetIntValue("level");
                        for (int j = 1; j <= level; j++)
                            ability.Level = j;
                    }
            }

            // restore original state
            Current.unit.Inventory.EnableMessages();

            UpdateHeroLeveling();
        }
Exemple #33
0
        internal void compactDump()
        {
            HabPropertiesCollection hpcHeroes = new HabPropertiesCollection();

            List<HabPropertiesCollection> unitHpcList = new List<HabPropertiesCollection>();
            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["Profile"]);
            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["UnitData"]);
            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["UnitWeapons"]);
            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["UnitBalance"]);
            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["UnitAbilities"]);

            HabPropertiesCollection hpcAbilities = new HabPropertiesCollection();

            List<HabPropertiesCollection> abilHpcList = new List<HabPropertiesCollection>();
            abilHpcList.Add(DHMpqDatabase.AbilitySlkDatabase["Profile"]);
            abilHpcList.Add(DHMpqDatabase.AbilitySlkDatabase["AbilityData"]);

            foreach (unit tavern in DHLOOKUP.taverns)
                foreach (string unitID in tavern.sellunits)
                {
                    HabProperties hps = new HabProperties();
                    foreach (HabPropertiesCollection hpc in unitHpcList)
                        hps.Merge(hpc[unitID]);

                    hps.name = unitID;

                    List<string> abils = hps.GetStringListValue("heroAbilList");
                    foreach (string abilID in abils)
                        if (!hpcAbilities.ContainsKey(abilID))
                        {
                            HabProperties hpsAbilData = new HabProperties();
                            foreach (HabPropertiesCollection hpcAbilData in abilHpcList)
                                hpsAbilData.Merge(hpcAbilData[abilID]);

                            hpsAbilData.name = abilID;

                            hpcAbilities.Add(hpsAbilData);
                        }

                    hpcHeroes.Add(hps);
                }

            List<string> filelist = new List<string>(2);

            if (heroesCB.Checked)
            {
                hpcHeroes.SaveToFile(Application.StartupPath + "\\" + "heroes.txt");
                filelist.Add("heroes.txt");
            }

            if (heroesAbilsCB.Checked)
            {
                hpcAbilities.SaveToFile(Application.StartupPath + "\\" + "heroes_abilities.txt");
                filelist.Add("heroes_abilities.txt");
            }

            string filenames = "";
            foreach (string filename in filelist)
                filenames += " " + filename + ",";

            MessageBox.Show("Data dumped to " + Application.StartupPath + "\nFiles:" + filenames.TrimEnd(','));
        }
Exemple #34
0
        public void showItemToolTip(HabProperties hpsItem, bool inventory)
        {
            UIRichTextEx.Default.ClearText();

            if (hpsItem == null) return;

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("Tip")), UIFonts.boldArial8, Color.White);//item.ID, UIFonts.boldArial8, Color.White);

            string gold = null;
            string mana = null;

            HabProperties hpsItemData;
            if (DHHELPER.IsNewVersionItem(hpsItem.name))
                hpsItemData = DHMpqDatabase.UnitSlkDatabase["UnitBalance"][hpsItem.name];
            else
                hpsItemData = DHMpqDatabase.ItemSlkDatabase["ItemData"][hpsItem.name];

            bool pawnable = DHFormatter.ToBool(hpsItemData.GetValue("pawnable"));
            DBINT goldcost = new DBINT(hpsItemData.GetValue("goldcost"));
            //int goldcost = DHFormatter.ToInt(hpsItemData.GetValue("goldcost"));

            if ((inventory && !pawnable) == false)
                gold = inventory ? (goldcost / 2) + "" : goldcost.Text;

            ShowPrices(mana, gold);

            tipRTB.Rtf = UIRichTextEx.Default.CloseRtf();

            UIRichTextEx.Default.ClearText();

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("UberTip")), UIFonts.boldArial8, Color.White);//item.description.Text, UIFonts.boldArial8, Color.White);

            ubertipRTB.Rtf = UIRichTextEx.Default.CloseRtf();
        }
Exemple #35
0
        private void PrepareReplayExport()
        {
            if (hpcExportCfg == null)
            {
                hpcExportCfg = new HabPropertiesCollection();
                hpcExportCfg.ReadFromFile(ReplayExportCfgFileName);
            }

            HabProperties hpsExportUI;
            if (!hpcExportCfg.TryGetValue("UI", out hpsExportUI))
            {
                hpsExportUI = new HabProperties();
                hpcExportCfg.Add("UI", hpsExportUI);
            }

            originalExport = string.Empty;

            exportPreviewB.Checked = false;

            int layout = hpsExportUI.GetIntValue("Layout", -1);

            if (currentExportLayout == layout)
                ShowReplayExport(layout);
            else
                layoutCmbB.SelectedIndex = layout;

            replayExportRTB.Font = new Font(
                hpsExportUI.GetStringValue("FontFamily", "Verdana"),
                (float)hpsExportUI.GetDoubleValue("FontSize", 10));

            fontTextBox.Text = replayExportRTB.Font.FontFamily.Name + " " + replayExportRTB.Font.Size;

            shortLaneNamesCB.Checked = hpsExportUI.GetIntValue("ShortLaneNames", 0) == 1;
            exportIconWidthNumUD.Value = (decimal)hpsExportUI.GetIntValue("ImageWidth", 18);
        }
Exemple #36
0
        public void showComplexItemToolTip(HabProperties hpsItem, int goldCost)
        {
            UIRichTextEx.Default.ClearText();

            if (hpsItem == null) return;

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("Tip")), UIFonts.boldArial8, Color.White);//item.ID, UIFonts.boldArial8, Color.White);

            string gold = (goldCost == 0) ? "" : goldCost + "";

            HabProperties hpsItemData = DHMpqDatabase.ItemSlkDatabase["ItemData"][hpsItem.name];

            ShowCopmlexItemPrice(gold);

            tipRTB.Rtf = UIRichTextEx.Default.CloseRtf();

            UIRichTextEx.Default.ClearText();

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsItem.GetValue("UberTip")), UIFonts.boldArial8, Color.White);//item.description.Text, UIFonts.boldArial8, Color.White);

            ubertipRTB.Rtf = UIRichTextEx.Default.CloseRtf();
        }
Exemple #37
0
 AbilityAffinityType CheckAbilityAffinity(HabProperties hpsAbility, string name, string hotkey, string buttonPos)
 {
     object abilityName;
     if (hpsAbility.TryGetValue("Name", out abilityName) && string.Equals(abilityName as string, name, StringComparison.OrdinalIgnoreCase))
     {
         // used when one ability can be replaced with another same looking ability
         // which leads to invalid hotkeys for that ability (example: Carrion Swarm)
         if ((hpsAbility.GetStringValue("Hotkey") == hotkey )
             && (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
             return AbilityAffinityType.Clone;
         else
             // used when hero has multiple abilities with the same name,
             // which are added by triggers (example: Shadowraze)
             // NOTE: must be later checked for user-defined hotkey existance to make sure
             return AbilityAffinityType.Variation;
     }
     else
         return AbilityAffinityType.None;
 }
Exemple #38
0
        // used when hero has multiple abilities with the same name,
        // which are added by triggers (example: Shadowraze)
        internal string GetAbilityVariations(HabProperties hpsOriginalAbility)
        {
            string name = hpsOriginalAbility.GetStringValue("Name");
            string art = hpsOriginalAbility.GetStringValue("Art");
            string hotkey;

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                if ((hpsAbility.GetStringValue("Name") == name)
                    && (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                    && (hpsOriginalAbility.name != hpsAbility.name)
                    && dcAbilitiesHotkeys.TryGetValue(hpsAbility.name, out hotkey))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }

            return output;
        }
Exemple #39
0
        internal string GetAbilityClones(HabProperties hpsOriginalAbility, string hotkey)
        {
            string name = hpsOriginalAbility.GetStringValue("Name");
            string art = hpsOriginalAbility.GetStringValue("Art");
            string orgHotkey = hpsOriginalAbility.GetStringValue("Hotkey");
            string buttonPos = hpsOriginalAbility.GetStringValue("Buttonpos");

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                if ((hpsAbility.GetStringValue("Name") == name)
                    && (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                    && (hpsAbility.GetStringValue("Hotkey") == orgHotkey)
                    && (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }

            return output;
        }
Exemple #40
0
        public void showHeroToolTip(HabProperties hpsHero)
        {
            this.Visible = false;
            UIRichTextEx.Default.ClearText();

            if (hpsHero == null) return;

            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsHero.GetValue("Tip")), UIFonts.boldArial8, Color.White);

            tipRTB.Rtf = UIRichTextEx.Default.CloseRtf();

            ShowPrices(null, hpsHero.GetValue("goldcost")+"");

            UIRichTextEx.Default.ClearText();
            UIRichTextEx.Default.AddTaggedText(DHFormatter.ToString(hpsHero.GetStringListValue("Ubertip")), UIFonts.boldArial8, Color.White);
            ubertipRTB.Rtf = UIRichTextEx.Default.CloseRtf();
        }
Exemple #41
0
        void ShowReplayExport(int layoutType)
        {
            if (hpcExportCfg["HeroTags"] == null)
                hpcExportCfg["HeroTags"] = new HabProperties();
            currentExportLayout = layoutType;

            Team t1;
            Team t2;

            dcUsedHeroTags = new Dictionary<string, string>();

            UIRichText.Default.ClearText();
            UIRichText.Default.buffer.Font = replayExportRTB.Font;
            UIRichText.Default.buffer.SelectionFont = replayExportRTB.Font;

            switch (layoutType)
            {
                case 0:
                    UIRichText.Default.AddText("The Sentinel\n");
                    t1 = currentReplay.GetTeamByType(TeamType.Sentinel);
                    appendLineUpToExport(t1, LineUp.Top, true); UIRichText.Default.AddText("\n");
                    appendLineUpToExport(t1, LineUp.Middle, true); UIRichText.Default.AddText("\n");
                    appendLineUpToExport(t1, LineUp.Bottom, true); UIRichText.Default.AddText("\n");
                    appendLineUpToExport(t1, LineUp.JungleOrRoaming, true); UIRichText.Default.AddText("\n");
                    UIRichText.Default.AddText("The Scourge\n");
                    t2 = currentReplay.GetTeamByType(TeamType.Scourge);
                    appendLineUpToExport(t2, LineUp.Top, true); UIRichText.Default.AddText("\n");
                    appendLineUpToExport(t2, LineUp.Middle, true); UIRichText.Default.AddText("\n");
                    appendLineUpToExport(t2, LineUp.Bottom, true); UIRichText.Default.AddText("\n");
                    appendLineUpToExport(t2, LineUp.JungleOrRoaming, true); UIRichText.Default.AddText("\n");
                    break;

                case 1:
                    t1 = currentReplay.GetTeamByType(TeamType.Sentinel);

                    UIRichText.Default.AddText(getLaneName(LineUp.Top) + ":  "); appendLineUpToExport(t1, LineUp.Top, false); UIRichText.Default.AddText("\n");
                    UIRichText.Default.AddText(getLaneName(LineUp.Middle) + ":  "); appendLineUpToExport(t1, LineUp.Middle, false); UIRichText.Default.AddText("\n");
                    UIRichText.Default.AddText(getLaneName(LineUp.Bottom) + ":  "); appendLineUpToExport(t1, LineUp.Bottom, false); UIRichText.Default.AddText("\n");
                    UIRichText.Default.AddText(getLaneName(LineUp.JungleOrRoaming) + ":  "); appendLineUpToExport(t1, LineUp.JungleOrRoaming, false);

                    rightAlignRtfLines(UIRichText.Default.buffer);

                    t2 = currentReplay.GetTeamByType(TeamType.Scourge);

                    string[] lines = UIRichText.Default.buffer.Lines;
                    lines[0] += "   vs   " + getHorzLineUp(t2, LineUp.Top);
                    lines[1] += "   vs   " + getHorzLineUp(t2, LineUp.Middle);
                    lines[2] += "   vs   " + getHorzLineUp(t2, LineUp.Bottom);
                    lines[3] += "        " + getHorzLineUp(t2, LineUp.JungleOrRoaming);

                    UIRichText.Default.buffer.Lines = lines;
                    break;

                case -1:
                    UIRichText.Default.AddText("Select layout first");
                    break;
            }

            UIRichText.Default.buffer.SelectAll();
            UIRichText.Default.buffer.SelectionFont = replayExportRTB.Font;
            replayExportRTB.Rtf = UIRichText.Default.buffer.Rtf;

            originalExport = replayExportRTB.Rtf;

            UIRichText.Default.ClearText();
        }