// // SkillsExtensions.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using NosSmooth.Game.Data.Characters; using Remora.Results; namespace NosSmooth.Game.Extensions; /// /// Contains extension methods for . /// public static class SkillsExtensions { /// /// Tries to get the skill of the specified vnum. /// /// The skills of the player. /// The vnum to search for. /// The skill, if found. public static Result TryGetSkill(this Skills skills, long skillVNum) { if (skills.PrimarySkill.SkillVNum == skillVNum) { return skills.PrimarySkill; } if (skills.SecondarySkill.SkillVNum == skillVNum) { return skills.SecondarySkill; } foreach (Skill skill in skills.OtherSkills) { if (skill.SkillVNum == skillVNum) { return skill; } } return new NotFoundError(); } }