//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions;
using System.Runtime.InteropServices;
using MUnique.OpenMU.DataModel.Configuration.Items;
using MUnique.OpenMU.PlugIns;
///
/// The summoning orb consume handler.
/// There is only one "Orb" item definition which allows to learn different skills, depending on the item level.
/// This consume handler determines the skill by adding the item level to the skill number
/// of the .
///
[Guid("71C8E542-4868-487E-BC92-0B7CC7CAEC8B")]
[PlugIn]
[Display(Name = nameof(PlugInResources.SummoningOrbConsumeHandlerPlugIn_Name), Description = nameof(PlugInResources.SummoningOrbConsumeHandlerPlugIn_Description), ResourceType = typeof(PlugInResources))]
public class SummoningOrbConsumeHandlerPlugIn : LearnablesConsumeHandlerPlugIn
{
///
public override ItemIdentifier Key => ItemConstants.SummonOrb;
///
/// Gets the learnable skill.
///
/// The item.
/// The game configuration.
///
/// The skill to learn.
///
protected override Skill GetLearnableSkill(Item item, GameConfiguration gameConfiguration)
{
item.ThrowNotInitializedProperty(item.Definition?.Skill is null, "Definition.Skill");
var baseSkillNumber = item.Definition.Skill.Number;
var targetSkillNumber = baseSkillNumber + item.Level;
return gameConfiguration.Skills.First(s => s.Number == targetSkillNumber);
}
}