private static string GetCreatureSiblingsText(Creature creature)
 {
     if (creature.TownIndex <= 8)
     {
         return(creature.Plural1.ChangeFirstCharCase() + " or " + CreatureManager.GetByCreatureIndex(creature.CreatureIndex + 1).Plural1.ChangeFirstCharCase());
     }
     return(creature.Plural1.ChangeFirstCharCase());
 }
        private static string GenerateCustomSpecText(HeroExeData hero)
        {
            string title = "", shortDescription = "", longDescription = "";
            var    spec = hero.Spec;

            // if spec is secondary skill, it would be found in original data;

            if (spec.Type == SpecialityType.CreatureLevelBonus)
            {
                var creature = CreatureManager.GetByCreatureIndex(spec.ObjectId);
                title            = creature.Plural1.ChangeFirstCharCase();
                shortDescription = "Creature Bonus: " + creature.Plural1.ChangeFirstCharCase();
                if (creature.TownIndex <= 8)
                {
                    longDescription = string.Format("Increases Speed of any {0} by 1 and their Attack and Defense skills by 5% for every {1} (rounded up)."
                                                    , GetCreatureSiblingsText(creature),
                                                    creature.CreatureTownLevel == 1 ? "level" : (creature.CreatureTownLevel + " levels"));
                }
                else
                {
                    longDescription = string.Format("Increases Speed of any {0} by 1 and their Attack and Defense skills by 5% for every 4 levels (rounded up).", creature.Plural1.ChangeFirstCharCase());
                }
            }
            else if (spec.Type == SpecialityType.Resource)
            {
                int d = 1;
                if (spec.ObjectId == (int)ResourceSpeciality.Gold350)
                {
                    d = 350;
                }

                string resourceType = Enum.GetName(typeof(ResourceSpeciality), spec.ObjectId);
                title            = "+ " + d + " " + resourceType;
                shortDescription = title + " each day.";
                longDescription  = "Increases kingdom's " + resourceType.ChangeFirstCharCase(false) + " production by " + d + " per day.";
            }
            else if (spec.Type == SpecialityType.Spell)
            {
                var spell = Spell.GetSpellByIndex(spec.ObjectId);

                title            = spell.Name;
                shortDescription = "Spell Bonus: " + spell.Name;
                longDescription  = "Casts " + spell.Name + "with effect increased by 3% for every n hero levels, where n is the level of the targeted creature.";
            }
            else if (spec.Type == SpecialityType.CreatureStaticBonus)
            {
                var creature = CreatureManager.GetByCreatureIndex(spec.ObjectId);

                int attack, defense, damage;
                spec.TryGetCreatureStaticBonuses(out attack, out defense, out damage);

                title            = creature.Plural1.ChangeFirstCharCase();
                shortDescription = "Creature Bonus: " + title;

                longDescription  = GetCreatureSiblingsText(creature);
                longDescription += " receive ";

                if (attack != 0)
                {
                    longDescription += " +" + attack + " Attack";
                }
                if (defense != 0)
                {
                    longDescription += " +" + defense + " Attack";
                }
                if (damage != 0)
                {
                    longDescription += " +" + damage + " Damage";
                }
            }
            else if (spec.Type == SpecialityType.CreaturesUpgrade)
            {
                int crFrom2 = BitConverter.ToInt32(spec.Data, 12);
                int crTo    = BitConverter.ToInt32(spec.Data, 16);

                title            = CreatureManager.GetByCreatureIndex(crTo).Plural1.ChangeFirstCharCase();
                shortDescription = "Creature Bonus: " + title;
                if (crFrom2 >= 0 || spec.ObjectId >= 0)
                {
                    longDescription = "Can upgrade ";
                    if (spec.ObjectId >= 0)
                    {
                        longDescription += GetCreatureSiblingsText(CreatureManager.GetByCreatureIndex(spec.ObjectId));
                    }

                    if (crFrom2 >= 0 && spec.ObjectId >= 0)
                    {
                        longDescription += " and ";
                    }

                    if (crFrom2 >= 0)
                    {
                        longDescription += GetCreatureSiblingsText(CreatureManager.GetByCreatureIndex(crFrom2));
                    }

                    longDescription += " to " + title;
                }
                else
                {
                    longDescription = shortDescription;
                }
            }
            return(string.Format("{0}\t{1}\t{2}", title, shortDescription, longDescription));
        }
Ejemplo n.º 3
0
        public string GetDescription()
        {
            string s = Type + " | ";

            if (TypeId == 0)
            {
                s += SecondarySkill.AllSkills[ObjectId];
            }
            else if (TypeId == 1)
            {
                s += CreatureManager.GetByCreatureIndex(ObjectId);
            }
            else if (TypeId == 2)
            {
                if (Enum.IsDefined(typeof(ResourceSpeciality), ObjectId))
                {
                    s += Enum.GetName(typeof(ResourceSpeciality), ObjectId);
                }
            }
            else if (TypeId == 3)
            {
                s += Spell.GetSpellByIndex(ObjectId);
            }
            else if (TypeId == 4)
            {
                s += CreatureManager.GetByCreatureIndex(ObjectId);

                int attack, defense, damage;

                TryGetCreatureStaticBonuses(out attack, out defense, out damage);

                if (attack != 0)
                {
                    s += " A: +" + attack;
                }
                if (defense != 0)
                {
                    s += " D: +" + defense;
                }
                if (damage != 0)
                {
                    s += " DMG: +" + damage;
                }
            }
            else if (TypeId == 5)
            {
                s += "+2 Speed";
            }
            else if (TypeId == 6)
            {
                int crFrom2 = BitConverter.ToInt32(Data, 12);
                int crTo    = BitConverter.ToInt32(Data, 16);

                s += "Creature Upgrade: From (";
                s += CreatureManager.GetByCreatureIndex(ObjectId);
                s += " AND ";
                s += CreatureManager.GetByCreatureIndex(crFrom2);
                s += ") To";
                s += CreatureManager.GetByCreatureIndex(crTo);
            }
            else if (TypeId == 7 || TypeId == -1)
            {
                s += Enum.GetName(typeof(SpecialityType), ObjectId);
            }
            return(s);
        }