예제 #1
0
        public virtual bool CanTrain(PlayerEntity mobile, out Skill skill, out TrainingEntry entry)
        {
            entry = default(TrainingEntry);

            skill = Skill.Hand;

            if (mobile.RightHand is Weapon weapon)
            {
                skill = weapon.Skill;
            }
            else if (mobile.RightHand is Spellbook spellbook)
            {
                if (spellbook.Owner != mobile)
                {
                    SayTo(mobile, 6300254);                     /* That spell book does not belong to you!*/
                    return(false);
                }

                skill = Skill.Magic;
            }
            else if (mobile.RightHand != default(ItemEntity))
            {
                SayTo(mobile, 6300238);                 /* I don't know how to train you with that item. */
                return(false);
            }

            if (CanTrain(skill, out entry) && CanTrain(mobile.Profession))
            {
                var skillLevel = mobile.GetSkillLevel(skill);

                if (skillLevel < entry.Minimum)
                {
                    SayTo(mobile, 6300240);                     /* Come back when you have become more skilled. */
                }
                else if (skillLevel > entry.Maximum)
                {
                    SayTo(mobile, 6300241);                     /* I can teach you no more. */
                }
                else if (mobile.Profession != Profession.MartialArtist && skill == Skill.Hand && skillLevel >= 6.0)
                {
                    SayTo(mobile, 6300242);                     /* You can learn more only by practicing. */
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                SayTo(mobile, 6300239);                 /* I cannot train you in that discipline. */
            }

            return(false);
        }
예제 #2
0
 /// <summary>
 /// Determines whether this instance can train the specified skill.
 /// </summary>
 private bool CanTrain(Skill skill, out TrainingEntry entry)
 {
     return(_training.TryGetValue(skill, out entry));
 }