Пример #1
0
        public static void AdjustCreatureLevel(ICreature creature, int delta)
        {
            // HP
            if (creature.Role is ComplexRole)
            {
                ComplexRole role = creature.Role as ComplexRole;

                int hp = 8;
                switch (role.Type)
                {
                case RoleType.Artillery:
                case RoleType.Lurker:
                    hp = 6;
                    break;

                case RoleType.Brute:
                    hp = 10;
                    break;
                }

                switch (role.Flag)
                {
                case RoleFlag.Elite:
                    hp *= 2;
                    break;

                case RoleFlag.Solo:
                    hp *= 5;
                    break;
                }

                creature.HP += hp * delta;
                creature.HP  = Math.Max(creature.HP, 1);
            }

            // Init
            int init_bonus = creature.Initiative - (creature.Level / 2);

            creature.Initiative = init_bonus + ((creature.Level + delta) / 2);

            // Defences
            creature.AC        += delta;
            creature.Fortitude += delta;
            creature.Reflex    += delta;
            creature.Will      += delta;

            // Powers
            foreach (CreaturePower cp in creature.CreaturePowers)
            {
                AdjustPowerLevel(cp, delta);
            }

            // Skills
            if (creature.Skills != "")
            {
                // Parse string
                Dictionary <string, int> skill_list = CreatureHelper.ParseSkills(creature.Skills);

                // Sort
                BinarySearchTree <string> bst = new BinarySearchTree <string>();
                foreach (string skill_name in skill_list.Keys)
                {
                    bst.Add(skill_name);
                }

                string skill_str = "";
                foreach (string skill_name in bst.SortedList)
                {
                    if (skill_str != "")
                    {
                        skill_str += ", ";
                    }

                    int mod = skill_list[skill_name];

                    // Apply level adjustment
                    int bonus = mod - (creature.Level / 2);
                    mod = bonus + ((creature.Level + delta) / 2);

                    if (mod >= 0)
                    {
                        skill_str += skill_name + " +" + mod;
                    }
                    else
                    {
                        skill_str += skill_name + " " + mod;
                    }
                }

                creature.Skills = skill_str;
            }

            // Level
            creature.Level += delta;
        }
Пример #2
0
        public static void AdjustCreatureLevel(ICreature creature, int delta)
        {
            if (creature.Role is ComplexRole)
            {
                ComplexRole role = creature.Role as ComplexRole;
                int         num  = 8;
                switch (role.Type)
                {
                case RoleType.Artillery:
                case RoleType.Lurker:
                {
                    num = 6;
                    goto case RoleType.Controller;
                }

                case RoleType.Blaster:
                case RoleType.Controller:
                {
                    switch (role.Flag)
                    {
                    case RoleFlag.Elite:
                    {
                        num *= 2;
                        break;
                    }

                    case RoleFlag.Solo:
                    {
                        num *= 5;
                        break;
                    }
                    }
                    ICreature hP = creature;
                    hP.HP       = hP.HP + num * delta;
                    creature.HP = Math.Max(creature.HP, 1);
                    break;
                }

                case RoleType.Brute:
                {
                    num = 10;
                    goto case RoleType.Controller;
                }

                default:
                {
                    goto case RoleType.Controller;
                }
                }
            }
            int initiative = creature.Initiative - creature.Level / 2;

            creature.Initiative = initiative + (creature.Level + delta) / 2;
            ICreature aC = creature;

            aC.AC = aC.AC + delta;
            ICreature fortitude = creature;

            fortitude.Fortitude = fortitude.Fortitude + delta;
            ICreature reflex = creature;

            reflex.Reflex = reflex.Reflex + delta;
            ICreature will = creature;

            will.Will = will.Will + delta;
            foreach (CreaturePower creaturePower in creature.CreaturePowers)
            {
                CreatureHelper.AdjustPowerLevel(creaturePower, delta);
            }
            if (creature.Skills != "")
            {
                Dictionary <string, int>  strs             = CreatureHelper.ParseSkills(creature.Skills);
                BinarySearchTree <string> binarySearchTree = new BinarySearchTree <string>();
                foreach (string key in strs.Keys)
                {
                    binarySearchTree.Add(key);
                }
                string str = "";
                foreach (string sortedList in binarySearchTree.SortedList)
                {
                    if (str != "")
                    {
                        str = string.Concat(str, ", ");
                    }
                    int item  = strs[sortedList];
                    int level = item - creature.Level / 2;
                    item = level + (creature.Level + delta) / 2;
                    if (item < 0)
                    {
                        object   obj      = str;
                        object[] objArray = new object[] { obj, sortedList, " ", item };
                        str = string.Concat(objArray);
                    }
                    else
                    {
                        object   obj1      = str;
                        object[] objArray1 = new object[] { obj1, sortedList, " +", item };
                        str = string.Concat(objArray1);
                    }
                }
                creature.Skills = str;
            }
            ICreature level1 = creature;

            level1.Level = level1.Level + delta;
        }