示例#1
0
        private static LifeDrain ParseLifeDrainCombatData(XElement element)
        {
            LifeDrain lifeDrain = new LifeDrain();

            if (element.Attribute("min") is XAttribute minAttribute)
            {
                lifeDrain.Min = short.Parse(minAttribute.Value);
            }

            if (element.Attribute("max") is XAttribute maxAttribute)
            {
                lifeDrain.Max = short.Parse(maxAttribute.Value);
            }

            return(lifeDrain);
        }
示例#2
0
        //Modified code from BasicSpellFactory.cs
        public Skill CreateSkill(Player player)
        {
            List <Skill> playerSkills = player.ListOfSkills;
            Skill        known        = CheckContent(playerSkills);

            if (known == null)
            {
                Skill        s1  = new ForcedLightning();
                Skill        s2  = new ConstrainPerson();
                Skill        s3  = new LifeDrain();
                List <Skill> tmp = new List <Skill>();
                if (s1.MinimumLevel <= player.Level)
                {
                    tmp.Add(s1);                                  // check level requirements
                }
                if (s2.MinimumLevel <= player.Level)
                {
                    tmp.Add(s2);
                }
                if (s3.MinimumLevel <= player.Level)
                {
                    tmp.Add(s3);
                }
                if (tmp.Count == 0)
                {
                    return(null);
                }
                return(tmp[Index.RNG(0, tmp.Count)]); // use Index.RNG for safe random numbers
            }
            else if (known.decoratedSkill == null)    // a BasicSpell has been already learned, use decorator to create a combo
            {
                Skill        s1  = new ForcedLightningDecorator(known);
                Skill        s2  = new ConstrainPersonDecorator(known);
                Skill        s3  = new LifeDrainDecorator(known);
                List <Skill> tmp = new List <Skill>();
                if (s1.MinimumLevel <= player.Level)
                {
                    tmp.Add(s1);                                  // check level requirements
                }
                if (s2.MinimumLevel <= player.Level)
                {
                    tmp.Add(s2);
                }
                if (s3.MinimumLevel <= player.Level)
                {
                    tmp.Add(s3);
                }
                if (tmp.Count == 0)
                {
                    return(null);
                }
                return(tmp[Index.RNG(0, tmp.Count)]);
            }
            else if (player.Level >= 6) //a double combo for players with lvl over 5
            {
                Skill        s1  = new ForcedLightningDecorator(known);
                Skill        s2  = new ConstrainPersonDecorator(known);
                Skill        s3  = new LifeDrainDecorator(known);
                List <Skill> tmp = new List <Skill>();
                if (s1.MinimumLevel <= player.Level)
                {
                    tmp.Add(s1);                                  // check level requirements
                }
                if (s2.MinimumLevel <= player.Level)
                {
                    tmp.Add(s2);
                }
                if (s3.MinimumLevel <= player.Level)
                {
                    tmp.Add(s3);
                }
                if (tmp.Count == 0)
                {
                    return(null);
                }
                return(tmp[Index.RNG(0, tmp.Count)]);
            }
            else
            {
                return(null);
            }
        }